Skip to content

Commit

Permalink
Merge pull request #34057 from Expensify/tgolen-refactor-reportaction…
Browse files Browse the repository at this point in the history
…itemremovesideloading

Load parent report action from withOnyx in ReportActionItem
  • Loading branch information
tgolen authored Jan 9, 2024
2 parents 0f2e55b + c89290b commit a144af4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ const propTypes = {

/** The user's wallet account */
userWallet: userWalletPropTypes,

/** All the report actions belonging to the report's parent */
parentReportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)),
};

const defaultProps = {
Expand All @@ -127,6 +130,7 @@ const defaultProps = {
iouReport: undefined,
shouldHideThreadDividerLine: false,
userWallet: {},
parentReportActions: {},
};

function ReportActionItem(props) {
Expand Down Expand Up @@ -568,7 +572,7 @@ function ReportActionItem(props) {
};

if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) {
const parentReportAction = ReportActionsUtils.getParentReportAction(props.report);
const parentReportAction = props.parentReportActions[props.report.parentReportActionID];
if (ReportActionsUtils.isTransactionThread(parentReportAction)) {
return (
<ShowContextMenuContext.Provider value={contextValue}>
Expand Down Expand Up @@ -769,6 +773,10 @@ export default compose(
userWallet: {
key: ONYXKEYS.USER_WALLET,
},
parentReportActions: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID || 0}`,
canEvict: false,
},
}),
)(
memo(
Expand All @@ -786,6 +794,8 @@ export default compose(
_.isEqual(prevProps.report.errorFields, nextProps.report.errorFields) &&
lodashGet(prevProps.report, 'statusNum') === lodashGet(nextProps.report, 'statusNum') &&
lodashGet(prevProps.report, 'stateNum') === lodashGet(nextProps.report, 'stateNum') &&
lodashGet(prevProps.report, 'parentReportID') === lodashGet(nextProps.report, 'parentReportID') &&
lodashGet(prevProps.report, 'parentReportActionID') === lodashGet(nextProps.report, 'parentReportActionID') &&
prevProps.translate === nextProps.translate &&
// TaskReport's created actions render the TaskView, which updates depending on certain fields in the TaskReport
ReportUtils.isTaskReport(prevProps.report) === ReportUtils.isTaskReport(nextProps.report) &&
Expand Down

0 comments on commit a144af4

Please sign in to comment.