From 5d9fced3f21a340941405a35a092ddd3bf2e94d0 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Tue, 16 Jan 2024 12:59:04 +0200 Subject: [PATCH 1/2] Fix accessing undefined parentReportActions object --- src/components/ReportActionItem/MoneyRequestView.js | 5 ++--- src/pages/home/ReportScreen.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 7c7998c24c95..36f9f4957284 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -427,9 +427,8 @@ export default compose( withOnyx({ transaction: { key: ({report, parentReportActions}) => { - const parentReportAction = parentReportActions[report.parentReportActionID]; - const transactionID = lodashGet(parentReportAction, ['originalMessage', 'IOUTransactionID'], 0); - return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; + const parentReportAction = lodashGet(parentReportActions, [report.parentReportActionID]); + return `${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', 0)}`; }, }, transactionViolations: { diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index b35d9240f3f7..1290f2dc082a 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -613,7 +613,7 @@ export default compose( if (!parentReportActionID) { return {}; } - return parentReportActions[parentReportActionID]; + return lodashGet(parentReportActions, parentReportActionID); }, canEvict: false, }, From 303ee2c8bcc2d32a402bc5fa58518619887750f5 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Wed, 17 Jan 2024 17:17:09 +0200 Subject: [PATCH 2/2] Minor edit --- src/components/ReportActionItem/MoneyRequestView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 36f9f4957284..c624562efa69 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -428,7 +428,8 @@ export default compose( transaction: { key: ({report, parentReportActions}) => { const parentReportAction = lodashGet(parentReportActions, [report.parentReportActionID]); - return `${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', 0)}`; + const transactionID = lodashGet(parentReportAction, ['originalMessage', 'IOUTransactionID'], 0); + return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; }, }, transactionViolations: {