Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated method and pass down parentReportAction #37449

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ function ReportScreen({
<ReportActionsView
reportActions={reportActions}
report={report}
parentReportAction={parentReportAction}
isLoadingInitialReportActions={reportMetadata.isLoadingInitialReportActions}
isLoadingNewerReportActions={reportMetadata.isLoadingNewerReportActions}
isLoadingOlderReportActions={reportMetadata.isLoadingOlderReportActions}
Expand Down
8 changes: 7 additions & 1 deletion src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const propTypes = {
/** The report currently being looked at */
report: reportPropTypes.isRequired,

/** The report's parentReportAction */
parentReportAction: PropTypes.shape(reportActionPropTypes),

/** Sorted actions prepared for display */
sortedReportActions: PropTypes.arrayOf(PropTypes.shape(reportActionPropTypes)).isRequired,

Expand Down Expand Up @@ -79,6 +82,7 @@ const defaultProps = {
isLoadingNewerReportActions: false,
...withCurrentUserPersonalDetailsDefaultProps,
policy: {},
parentReportAction: {},
};

const VERTICAL_OFFSET_THRESHOLD = 200;
Expand Down Expand Up @@ -123,6 +127,7 @@ function isMessageUnread(message, lastReadTime) {

function ReportActionsList({
report,
parentReportAction,
isLoadingInitialReportActions,
isLoadingOlderReportActions,
isLoadingNewerReportActions,
Expand Down Expand Up @@ -412,6 +417,7 @@ function ReportActionsList({
({item: reportAction, index}) => (
<ReportActionsListItemRenderer
reportAction={reportAction}
parentReportAction={parentReportAction}
index={index}
report={report}
linkedReportActionID={linkedReportActionID}
Expand All @@ -421,7 +427,7 @@ function ReportActionsList({
shouldDisplayNewMarker={shouldDisplayNewMarker(reportAction, index)}
/>
),
[report, linkedReportActionID, sortedReportActions, mostRecentIOUReportActionID, shouldHideThreadDividerLine, shouldDisplayNewMarker],
[report, linkedReportActionID, sortedReportActions, mostRecentIOUReportActionID, shouldHideThreadDividerLine, shouldDisplayNewMarker, parentReportAction],
);

// Native mobile does not render updates flatlist the changes even though component did update called.
Expand Down
11 changes: 8 additions & 3 deletions src/pages/home/report/ReportActionsListItemRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const propTypes = {
/** All the data of the action item */
reportAction: PropTypes.shape(reportActionPropTypes).isRequired,

/** The report's parentReportAction */
parentReportAction: PropTypes.shape(reportActionPropTypes),

/** Position index of the report action in the overall report FlatList view */
index: PropTypes.number.isRequired,

Expand All @@ -38,10 +41,12 @@ const propTypes = {
const defaultProps = {
mostRecentIOUReportActionID: '',
linkedReportActionID: '',
parentReportAction: {},
};

function ReportActionsListItemRenderer({
reportAction,
parentReportAction,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't added to the memoization of the component which lead to a regression #37466

index,
report,
displayAsGroup,
Expand All @@ -51,9 +56,7 @@ function ReportActionsListItemRenderer({
linkedReportActionID,
}) {
const shouldDisplayParentAction =
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED &&
ReportUtils.isChatThread(report) &&
!ReportActionsUtils.isTransactionThread(ReportActionsUtils.getParentReportAction(report));
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && ReportUtils.isChatThread(report) && !ReportActionsUtils.isTransactionThread(parentReportAction);

/**
* Create a lightweight ReportAction so as to keep the re-rendering as light as possible by
Expand Down Expand Up @@ -120,6 +123,8 @@ function ReportActionsListItemRenderer({
],
);

console.debug('timddd', shouldDisplayParentAction);
tgolen marked this conversation as resolved.
Show resolved Hide resolved

return shouldDisplayParentAction ? (
<ReportActionItemParentAction
shouldHideThreadDividerLine={shouldDisplayParentAction && shouldHideThreadDividerLine}
Expand Down
5 changes: 5 additions & 0 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const propTypes = {
/** Array of report actions for this report */
reportActions: PropTypes.arrayOf(PropTypes.shape(reportActionPropTypes)),

/** The report's parentReportAction */
parentReportAction: PropTypes.shape(reportActionPropTypes),

/** The report metadata loading states */
isLoadingInitialReportActions: PropTypes.bool,

Expand Down Expand Up @@ -78,6 +81,7 @@ const defaultProps = {
session: {
authTokenType: '',
},
parentReportAction: {},
};

function ReportActionsView(props) {
Expand Down Expand Up @@ -254,6 +258,7 @@ function ReportActionsView(props) {
<>
<ReportActionsList
report={props.report}
parentReportAction={props.parentReportAction}
onLayout={recordTimeToMeasureItemLayout}
sortedReportActions={props.reportActions}
mostRecentIOUReportActionID={mostRecentIOUReportActionID}
Expand Down
Loading