From 636f82555ac538331120ae42097fac48078c4646 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Mon, 22 Apr 2024 19:44:43 +0530 Subject: [PATCH 1/2] Use fallback route --- src/libs/actions/Report.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 8b0dbf8a37a9..3e83281dc83f 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2468,7 +2468,8 @@ function navigateToMostRecentReport(currentReport: OnyxEntry) { if (lastAccessedReportID) { // If it is not a chat thread we should call Navigation.goBack to pop the current route first before navigating to last accessed report. if (!isChatThread) { - Navigation.goBack(); + // Fallback to the lastAccessedReportID route, if this is first route in the navigator + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID ?? '')); } Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID ?? ''), CONST.NAVIGATION.TYPE.FORCED_UP); } else { From ed7a5fe11e7f33dc27e3f9d661231bd4059df5bd Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Tue, 23 Apr 2024 13:51:58 +0530 Subject: [PATCH 2/2] Refactor code --- src/libs/actions/Report.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 3e83281dc83f..742e5fa296ea 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2466,12 +2466,13 @@ function navigateToMostRecentReport(currentReport: OnyxEntry) { const lastAccessedReportID = filteredReportsByLastRead.at(-1)?.reportID; const isChatThread = ReportUtils.isChatThread(currentReport); if (lastAccessedReportID) { + const lastAccessedReportRoute = ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID ?? ''); // If it is not a chat thread we should call Navigation.goBack to pop the current route first before navigating to last accessed report. if (!isChatThread) { // Fallback to the lastAccessedReportID route, if this is first route in the navigator - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID ?? '')); + Navigation.goBack(lastAccessedReportRoute); } - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID ?? ''), CONST.NAVIGATION.TYPE.FORCED_UP); + Navigation.navigate(lastAccessedReportRoute, CONST.NAVIGATION.TYPE.FORCED_UP); } else { const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.CONCIERGE]); const chat = ReportUtils.getChatByParticipants(participantAccountIDs);