From 6fd9e26b3cdd8b545e6dfd8547d24d774e2dbdcd Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Mon, 2 Dec 2024 13:22:15 -0800 Subject: [PATCH 1/3] FIX: Not found page shows briefly when deleting a track expense --- src/pages/home/report/withReportOrNotFound.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/home/report/withReportOrNotFound.tsx b/src/pages/home/report/withReportOrNotFound.tsx index 55fc168d3d7c..6fefd65bfdde 100644 --- a/src/pages/home/report/withReportOrNotFound.tsx +++ b/src/pages/home/report/withReportOrNotFound.tsx @@ -1,5 +1,4 @@ /* eslint-disable rulesdir/no-negated-variables */ -import {useIsFocused} from '@react-navigation/native'; import type {ComponentType, ForwardedRef, RefAttributes} from 'react'; import React, {useEffect} from 'react'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; @@ -66,7 +65,6 @@ export default function ( const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${props.route.params.reportID}`); const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${props.route.params.reportID}`); - const isFocused = useIsFocused(); const contentShown = React.useRef(false); const isReportIdInRoute = !!props.route.params.reportID?.length; const isReportLoaded = !isEmptyObject(report) && !!report?.reportID; @@ -93,7 +91,7 @@ export default function ( // If the content was shown, but it's not anymore, that means the report was deleted, and we are probably navigating out of this screen. // Return null for this case to avoid rendering FullScreenLoadingIndicator or NotFoundPage when animating transition. // eslint-disable-next-line react-compiler/react-compiler - if (shouldShowNotFoundPage && contentShown.current && !isFocused) { + if (shouldShowNotFoundPage && contentShown.current) { return null; } From 8019b25eb705160f87e54dd92f7392441347fc98 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Wed, 11 Dec 2024 20:41:10 -0800 Subject: [PATCH 2/3] 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} > From 4fb05dfa7a5fdf952dfd43f959565af393f7c2a5 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Wed, 11 Dec 2024 23:58:26 -0800 Subject: [PATCH 3/3] reverted last commit, fixed Navigation.goBack shouldPopToTop logic --- src/libs/Navigation/Navigation.ts | 3 ++- src/libs/actions/Report.ts | 12 ++---------- src/pages/Debug/Report/DebugReportPage.tsx | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index d54668bf3f69..9d8049930966 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -210,8 +210,9 @@ function goBack(fallbackRoute?: Route, shouldEnforceFallback = false, shouldPopT if (shouldPopToTop) { if (shouldPopAllStateOnUP) { + const rootState = navigationRef.getRootState(); shouldPopAllStateOnUP = false; - navigationRef.current?.dispatch(StackActions.popToTop()); + navigationRef.current?.dispatch({...StackActions.popToTop(), target: rootState.key}); return; } } diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index fc7aa37dca6e..06e339ea1696 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1,4 +1,4 @@ -import {findFocusedRoute, StackActions} from '@react-navigation/native'; +import {findFocusedRoute} from '@react-navigation/native'; import {format as timezoneFormat, toZonedTime} from 'date-fns-tz'; import {Str} from 'expensify-common'; import isEmpty from 'lodash/isEmpty'; @@ -2450,20 +2450,12 @@ function deleteReport(reportID: string, shouldDeleteChildReports = false) { /** * @param reportID The reportID of the policy report (workspace room) */ -function navigateToConciergeChatAndDeleteReport(reportID: string, shouldPopToTop = false, shouldDeleteChildReports = false, shouldPopTwice = false) { +function navigateToConciergeChatAndDeleteReport(reportID: string, shouldPopToTop = false, shouldDeleteChildReports = 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 5202c28ad11f..16e23ed4c608 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, false, true, true); + navigateToConciergeChatAndDeleteReport(reportID, true, true); }} validate={DebugUtils.validateReportDraftProperty} >