From 33c40c5fe05722b88f5a3e259af46922557878d6 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Fri, 5 Jan 2024 13:10:08 -0700 Subject: [PATCH 1/3] Load parent report action from withOnyx in ReportActionItem --- src/pages/home/report/ReportActionItem.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 435c086d913f..bb88c3d44224 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -117,6 +117,9 @@ const propTypes = { /** The user's wallet account */ userWallet: userWalletPropTypes, + + /** All the report action belonging the report's parent */ + parentReportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), }; const defaultProps = { @@ -127,6 +130,7 @@ const defaultProps = { iouReport: undefined, shouldHideThreadDividerLine: false, userWallet: {}, + parentReportActions: {}, }; function ReportActionItem(props) { @@ -569,7 +573,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 ( @@ -768,6 +772,10 @@ export default compose( userWallet: { key: ONYXKEYS.USER_WALLET, }, + parentReportActions: { + key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : 0}`, + canEvict: false, + }, }), )( memo( @@ -785,6 +793,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) && From e3758e0c3e8c146e95d099b89c50726ef13e1d34 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Mon, 8 Jan 2024 09:20:12 -0700 Subject: [PATCH 2/3] Update src/pages/home/report/ReportActionItem.js Co-authored-by: Amy Evans --- src/pages/home/report/ReportActionItem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index bb88c3d44224..4a060abb762a 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -118,7 +118,7 @@ const propTypes = { /** The user's wallet account */ userWallet: userWalletPropTypes, - /** All the report action belonging the report's parent */ + /** All the report actions belonging to the report's parent */ parentReportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), }; From c89290bccff93e22aa43e4090e442fda753ba0b0 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Mon, 8 Jan 2024 09:28:59 -0700 Subject: [PATCH 3/3] Remove unnecessary ternary --- src/pages/home/report/ReportActionItem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index a412fb2aa0bd..c81e0fe31a13 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -772,7 +772,7 @@ export default compose( key: ONYXKEYS.USER_WALLET, }, parentReportActions: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : 0}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID || 0}`, canEvict: false, }, }),