From 7c7fa17a2ccd2287a51552ff65d7fcdc34091eda Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 2 Jul 2024 15:42:10 +0800 Subject: [PATCH 1/4] clear report action ID only if it's a one transaction thread action --- src/pages/home/ReportScreen.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 3c2ae7bbc6e6..903122401267 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -289,6 +289,10 @@ function ReportScreen({ } return ReportActionsUtils.getContinuousReportActionChain(sortedAllReportActions, reportActionIDFromRoute); }, [reportActionIDFromRoute, sortedAllReportActions]); + const linkedAction = useMemo( + () => sortedAllReportActions.find((obj) => String(obj.reportActionID) === String(reportActionIDFromRoute)), + [reportActionIDFromRoute, sortedAllReportActions], + ); // Define here because reportActions are recalculated before mount, allowing data to display faster than useEffect can trigger. // If we have cached reportActions, they will be shown immediately. @@ -378,7 +382,7 @@ function ReportScreen({ } useEffect(() => { - if (!transactionThreadReportID || !route?.params?.reportActionID) { + if (!transactionThreadReportID || !route?.params?.reportActionID || !ReportUtils.isOneTransactionThread(linkedAction?.childReportID ?? '', report.reportID, linkedAction)) { return; } Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(route?.params?.reportID)); From 6ff7babbb78aaa3133556f0a88f384169892d6c6 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 2 Jul 2024 16:30:38 +0800 Subject: [PATCH 2/4] update default value --- src/pages/home/ReportScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 903122401267..f184244c0b93 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -382,7 +382,7 @@ function ReportScreen({ } useEffect(() => { - if (!transactionThreadReportID || !route?.params?.reportActionID || !ReportUtils.isOneTransactionThread(linkedAction?.childReportID ?? '', report.reportID, linkedAction)) { + if (!transactionThreadReportID || !route?.params?.reportActionID || !ReportUtils.isOneTransactionThread(linkedAction?.childReportID ?? '-1', report.reportID, linkedAction)) { return; } Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(route?.params?.reportID)); From 04d10b519f8f41dd5502bc9bf813fdfec05ad8c9 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 11 Jul 2024 21:28:24 +0800 Subject: [PATCH 3/4] prettier --- src/pages/home/ReportScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 1146692dbd5f..39ea7e8f74d1 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -294,7 +294,7 @@ function ReportScreen({ if (!sortedAllReportActions.length) { return []; } - + return PaginationUtils.getContinuousChain(sortedAllReportActions, reportActionPages ?? [], (reportAction) => reportAction.reportActionID, reportActionIDFromRoute); }, [reportActionIDFromRoute, sortedAllReportActions, reportActionPages]); const linkedAction = useMemo( From 5cea1ed8eb1861063eff5a3bd1014db69ad1c044 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 11 Jul 2024 21:39:15 +0800 Subject: [PATCH 4/4] add missing deps --- src/pages/home/ReportScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 39ea7e8f74d1..c7ce39ad630a 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -394,7 +394,7 @@ function ReportScreen({ return; } Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(route?.params?.reportID)); - }, [transactionThreadReportID, route?.params?.reportActionID, route?.params?.reportID]); + }, [transactionThreadReportID, route?.params?.reportActionID, route?.params?.reportID, linkedAction, report.reportID]); if (ReportUtils.isMoneyRequestReport(report) || ReportUtils.isInvoiceReport(report)) { headerView = (