From 7846542e617d2bd4eb6316a16e855b4154a23119 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Mon, 30 Dec 2024 10:11:35 +0100 Subject: [PATCH 1/3] fix app crash in group chat --- src/pages/ReportDetailsPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 15de7a6e5f4a..0456812ab636 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -87,9 +87,9 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const backTo = route.params.backTo; // 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. - const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); - const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.parentReportID}`); + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID ?? ''}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? ''}`); + const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.parentReportID ?? ''}`); const {reportActions} = usePaginatedReportActions(report.reportID); const {currentSearchHash} = useSearchContext(); From ab1c902a458df62cd94609e740f4706871af6648 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Mon, 30 Dec 2024 12:08:52 +0100 Subject: [PATCH 2/3] ignore no-default-id-values rule for report details --- src/pages/ReportDetailsPage.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 0456812ab636..f0e5ba2aa575 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -87,8 +87,11 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const backTo = route.params.backTo; // 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 rulesdir/no-default-id-values const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID ?? ''}`); + // eslint-disable-next-line rulesdir/no-default-id-values const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? ''}`); + // eslint-disable-next-line rulesdir/no-default-id-values const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.parentReportID ?? ''}`); const {reportActions} = usePaginatedReportActions(report.reportID); const {currentSearchHash} = useSearchContext(); From 36aff230e6fef5163f3cac5e0d8a9cf86a31c318 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Mon, 30 Dec 2024 13:11:32 +0100 Subject: [PATCH 3/3] use default ID instead of empty string --- src/pages/ReportDetailsPage.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index f0e5ba2aa575..4a674d6e80a1 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -87,12 +87,11 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const backTo = route.params.backTo; // 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 rulesdir/no-default-id-values - const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID ?? ''}`); - // eslint-disable-next-line rulesdir/no-default-id-values - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? ''}`); - // eslint-disable-next-line rulesdir/no-default-id-values - const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.parentReportID ?? ''}`); + /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || CONST.DEFAULT_NUMBER_ID}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || CONST.DEFAULT_NUMBER_ID}`); + const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.parentReportID || CONST.DEFAULT_NUMBER_ID}`); + /* eslint-enable @typescript-eslint/prefer-nullish-coalescing */ const {reportActions} = usePaginatedReportActions(report.reportID); const {currentSearchHash} = useSearchContext();