From ed7a5fe11e7f33dc27e3f9d661231bd4059df5bd Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Tue, 23 Apr 2024 13:51:58 +0530 Subject: [PATCH] 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);