From 8019b25eb705160f87e54dd92f7392441347fc98 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Wed, 11 Dec 2024 20:41:10 -0800 Subject: [PATCH] fixed navigation for Debug mode delete report --- src/libs/actions/Report.ts | 12 ++++++++++-- src/pages/Debug/Report/DebugReportPage.tsx | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 06e339ea1696..fc7aa37dca6e 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1,4 +1,4 @@ -import {findFocusedRoute} from '@react-navigation/native'; +import {findFocusedRoute, StackActions} from '@react-navigation/native'; import {format as timezoneFormat, toZonedTime} from 'date-fns-tz'; import {Str} from 'expensify-common'; import isEmpty from 'lodash/isEmpty'; @@ -2450,12 +2450,20 @@ function deleteReport(reportID: string, shouldDeleteChildReports = false) { /** * @param reportID The reportID of the policy report (workspace room) */ -function navigateToConciergeChatAndDeleteReport(reportID: string, shouldPopToTop = false, shouldDeleteChildReports = false) { +function navigateToConciergeChatAndDeleteReport(reportID: string, shouldPopToTop = false, shouldDeleteChildReports = false, shouldPopTwice = false) { // Dismiss the current report screen and replace it with Concierge Chat if (shouldPopToTop) { Navigation.setShouldPopAllStateOnUP(true); } Navigation.goBack(undefined, undefined, shouldPopToTop); + // When in Debug Mode and Delete report in DebugReportPage we need to pop + // two screens from the navigation stack before we navigate to Concierge report: + // ReportDetailsPage and ReportScreen, otherwise when going back from Concierge + // we'll see blank page for the first one and report skeleton loading for the second one. + if (shouldPopTwice) { + navigationRef.dispatch({...StackActions.pop()}); + navigationRef.dispatch({...StackActions.pop()}); + } navigateToConciergeChat(); InteractionManager.runAfterInteractions(() => { deleteReport(reportID, shouldDeleteChildReports); diff --git a/src/pages/Debug/Report/DebugReportPage.tsx b/src/pages/Debug/Report/DebugReportPage.tsx index 16e23ed4c608..5202c28ad11f 100644 --- a/src/pages/Debug/Report/DebugReportPage.tsx +++ b/src/pages/Debug/Report/DebugReportPage.tsx @@ -145,7 +145,7 @@ function DebugReportPage({ }} onDelete={() => { Debug.setDebugData(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, null); - navigateToConciergeChatAndDeleteReport(reportID, true, true); + navigateToConciergeChatAndDeleteReport(reportID, false, true, true); }} validate={DebugUtils.validateReportDraftProperty} >