Skip to content

Commit

Permalink
Merge pull request #37449 from Expensify/tgolen-refactor-sideloading-…
Browse files Browse the repository at this point in the history
…reportactionitem

Remove deprecated method and pass down parentReportAction
  • Loading branch information
srikarparsi authored Feb 28, 2024
2 parents 4cd33a3 + 815dae1 commit d9fea65
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
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
9 changes: 6 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,
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
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

0 comments on commit d9fea65

Please sign in to comment.