From b0e78912a9ced1d9ea73163218b90b35056c2b1a Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Thu, 27 Jun 2024 12:08:11 -0700 Subject: [PATCH] Merge pull request #44562 from Expensify/vit-44410 [CP Staging] Default to -1 in report header details (cherry picked from commit 11333a31d2050923bf2ed2395bb078d6d283fb48) --- src/pages/ReportDetailsPage.tsx | 5 ++++- src/pages/home/report/ReportActionItem.tsx | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 91f876250999..dcbad36d1eda 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -79,7 +79,10 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const {translate} = useLocalize(); const {isOffline} = useNetwork(); const styles = useThemeStyles(); - const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID ?? '-1'}`); + + // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || '-1'}`); const [sortedAllReportActions = []] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID ?? '-1'}`, { canEvict: false, selector: (allReportActions: OnyxEntry) => ReportActionsUtils.getSortedReportActionsForDisplay(allReportActions, true), diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index f7e9b4429e2b..81ff990a2e34 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -202,6 +202,7 @@ function ReportActionItem({ const downloadedPreviews = useRef([]); const prevDraftMessage = usePrevious(draftMessage); const originalReportID = ReportUtils.getOriginalReportID(report.reportID, action); + // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || -1}`);