Skip to content

Commit

Permalink
fixed navigation for Debug mode delete report
Browse files Browse the repository at this point in the history
  • Loading branch information
ikevin127 committed Dec 12, 2024
1 parent 59a2970 commit 8019b25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Debug/Report/DebugReportPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
>
Expand Down

0 comments on commit 8019b25

Please sign in to comment.