diff --git a/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts index f4c24165120b..12ea47f70b5b 100644 --- a/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts @@ -51,6 +51,7 @@ const useSplitNavigatorScreenOptions = () => { headerShown: false, title: CONFIG.SITE_TITLE, animation: shouldUseNarrowLayout ? undefined : Animations.NONE, + animationTypeForReplace: 'pop', web: { cardStyleInterpolator: (props: StackCardInterpolationProps) => modalCardStyleInterpolator({props, isFullScreenModal: true, shouldAnimateSidePanel: true}), cardStyle: shouldUseNarrowLayout ? StyleUtils.getNavigationModalCardStyle() : themeStyles.h100, diff --git a/src/libs/Navigation/NavigationRoot.tsx b/src/libs/Navigation/NavigationRoot.tsx index 6b7a9cbd13b9..81f577d784b9 100644 --- a/src/libs/Navigation/NavigationRoot.tsx +++ b/src/libs/Navigation/NavigationRoot.tsx @@ -167,7 +167,14 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N return; } - Navigation.setShouldPopAllStateOnUP(!shouldUseNarrowLayout); + // After resizing the screen from wide to narrow, if we have visited multiple central screens, we want to go back to the LHN screen, so we set shouldPopAllStateOnUP to true. + // Now when this value is true, Navigation.goBack with the option {shouldPopToTop: true} will remove all visited central screens in the given tab from the navigation stack and go back to the LHN. + // More context here: https://github.com/Expensify/App/pull/59300 + if (!shouldUseNarrowLayout) { + return; + } + + Navigation.setShouldPopAllStateOnUP(true); }, [shouldUseNarrowLayout]); useEffect(() => { diff --git a/src/libs/Navigation/helpers/goBackFromWorkspaceCentralScreen.ts b/src/libs/Navigation/helpers/goBackFromWorkspaceCentralScreen.ts new file mode 100644 index 000000000000..5324bff9be0e --- /dev/null +++ b/src/libs/Navigation/helpers/goBackFromWorkspaceCentralScreen.ts @@ -0,0 +1,28 @@ +import Log from '@libs/Log'; +import Navigation from '@libs/Navigation/Navigation'; +import navigationRef from '@libs/Navigation/navigationRef'; +import NAVIGATORS from '@src/NAVIGATORS'; +import ROUTES from '@src/ROUTES'; + +/** + * If there are already other screens open in WorkspaceSplitNavigator, we return to the previous one. + * If not, from the central screen in WorkspaceSplitNavigator we should return to the WorkspaceInitialPage. + */ +function goBackFromWorkspaceCentralScreen(policyID: string | undefined) { + const rootState = navigationRef.getRootState(); + const lastRoute = rootState.routes.at(-1); + + if (lastRoute?.name !== NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR) { + Log.hmmm('[goBackFromWorkspaceCentralScreen] goBackFromWorkspaceCentralScreen was called from a different navigator than WorkspaceSplitNavigator.'); + return; + } + + if (lastRoute.state?.routes && lastRoute.state.routes.length > 1) { + Navigation.goBack(undefined, {shouldPopToTop: true}); + return; + } + + Navigation.goBack(ROUTES.WORKSPACE_INITIAL.getRoute(policyID)); +} + +export default goBackFromWorkspaceCentralScreen; diff --git a/src/pages/TeachersUnite/SaveTheWorldPage.tsx b/src/pages/TeachersUnite/SaveTheWorldPage.tsx index f52d20ad9014..ce4c8b230f3c 100644 --- a/src/pages/TeachersUnite/SaveTheWorldPage.tsx +++ b/src/pages/TeachersUnite/SaveTheWorldPage.tsx @@ -57,7 +57,7 @@ function SaveTheWorldPage() { title={translate('sidebarScreen.saveTheWorld')} shouldShowBackButton={shouldUseNarrowLayout} shouldDisplaySearchRouter - onBackButtonPress={() => Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(undefined, {shouldPopToTop: true})} icon={Illustrations.TeachersUnite} shouldUseHeadlineHeader /> diff --git a/src/pages/settings/AboutPage/AboutPage.tsx b/src/pages/settings/AboutPage/AboutPage.tsx index 1f28c1565dd2..a0f86c2c2e26 100644 --- a/src/pages/settings/AboutPage/AboutPage.tsx +++ b/src/pages/settings/AboutPage/AboutPage.tsx @@ -142,7 +142,7 @@ function AboutPage() { title={translate('initialSettingsPage.about')} shouldShowBackButton={shouldUseNarrowLayout} shouldDisplaySearchRouter - onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS, {shouldPopToTop: true})} icon={Illustrations.PalmTree} shouldUseHeadlineHeader /> diff --git a/src/pages/settings/Preferences/PreferencesPage.tsx b/src/pages/settings/Preferences/PreferencesPage.tsx index 1b640dac39ae..2d9ac037cc69 100755 --- a/src/pages/settings/Preferences/PreferencesPage.tsx +++ b/src/pages/settings/Preferences/PreferencesPage.tsx @@ -53,7 +53,7 @@ function PreferencesPage() { shouldUseHeadlineHeader shouldShowBackButton={shouldUseNarrowLayout} shouldDisplaySearchRouter - onBackButtonPress={() => Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(undefined, {shouldPopToTop: true})} /> diff --git a/src/pages/settings/Profile/ProfilePage.tsx b/src/pages/settings/Profile/ProfilePage.tsx index 9e6b913bf08c..d83bef20e5cf 100755 --- a/src/pages/settings/Profile/ProfilePage.tsx +++ b/src/pages/settings/Profile/ProfilePage.tsx @@ -152,7 +152,7 @@ function ProfilePage() { > Navigation.goBack(route.params?.backTo)} + onBackButtonPress={() => Navigation.goBack(route.params?.backTo, {shouldPopToTop: true})} shouldShowBackButton={shouldUseNarrowLayout} shouldDisplaySearchRouter icon={Illustrations.Profile} diff --git a/src/pages/settings/Security/SecuritySettingsPage.tsx b/src/pages/settings/Security/SecuritySettingsPage.tsx index c73f1406dfc7..9ec999949fef 100644 --- a/src/pages/settings/Security/SecuritySettingsPage.tsx +++ b/src/pages/settings/Security/SecuritySettingsPage.tsx @@ -265,7 +265,7 @@ function SecuritySettingsPage() { Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(undefined, {shouldPopToTop: true})} icon={Illustrations.LockClosed} shouldUseHeadlineHeader shouldDisplaySearchRouter diff --git a/src/pages/settings/Subscription/SubscriptionSettingsPage.tsx b/src/pages/settings/Subscription/SubscriptionSettingsPage.tsx index 40be960ec950..46911ea6b8c0 100644 --- a/src/pages/settings/Subscription/SubscriptionSettingsPage.tsx +++ b/src/pages/settings/Subscription/SubscriptionSettingsPage.tsx @@ -51,7 +51,7 @@ function SubscriptionSettingsPage({route}: SubscriptionSettingsPageProps) { > Navigation.goBack(backTo)} + onBackButtonPress={() => Navigation.goBack(backTo, {shouldPopToTop: true})} shouldShowBackButton={shouldUseNarrowLayout} shouldDisplaySearchRouter icon={Illustrations.CreditCardsNew} diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index f7c040bb95f1..d23348bcad9d 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -108,7 +108,7 @@ function TroubleshootPage() { title={translate('initialSettingsPage.aboutPage.troubleshoot')} shouldShowBackButton={shouldUseNarrowLayout} shouldDisplaySearchRouter - onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS, {shouldPopToTop: true})} icon={Illustrations.Lightbulb} shouldUseHeadlineHeader /> diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx index ceb16efec872..8bd2e688cd6b 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx @@ -388,6 +388,7 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { shouldUseHeadlineHeader shouldShowBackButton={shouldUseNarrowLayout} shouldDisplaySearchRouter + onBackButtonPress={() => Navigation.goBack(undefined, {shouldPopToTop: true})} /> ); diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index f5262408487a..a9ca34bef40f 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -46,6 +46,7 @@ import {removeApprovalWorkflow as removeApprovalWorkflowAction, updateApprovalWo import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import {formatPhoneNumber as formatPhoneNumberUtil} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types'; @@ -680,7 +681,7 @@ function WorkspaceMembersPage({personalDetails, route, policy, currentUserPerson turnOffMobileSelectionMode(); return; } - Navigation.goBack(); + goBackFromWorkspaceCentralScreen(policyID); }} > {() => ( diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index fd091c77b376..d41d4eb93036 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -15,6 +15,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import {filterInactiveCards, getAllCardsForWorkspace, getCompanyFeeds, isSmartLimitEnabled as isSmartLimitEnabledUtil} from '@libs/CardUtils'; import {getLatestErrorField} from '@libs/ErrorUtils'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types'; @@ -465,6 +466,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro shouldUseHeadlineHeader title={translate('workspace.common.moreFeatures')} shouldShowBackButton={shouldUseNarrowLayout} + onBackButtonPress={() => goBackFromWorkspaceCentralScreen(policyID)} /> diff --git a/src/pages/workspace/WorkspaceOverviewPage.tsx b/src/pages/workspace/WorkspaceOverviewPage.tsx index d99aa0d84f56..26c9a132d2f4 100644 --- a/src/pages/workspace/WorkspaceOverviewPage.tsx +++ b/src/pages/workspace/WorkspaceOverviewPage.tsx @@ -31,6 +31,7 @@ import { } from '@libs/actions/Policy/Policy'; import {filterInactiveCards} from '@libs/CardUtils'; import {getLatestErrorField} from '@libs/ErrorUtils'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import resetPolicyIDInNavigationState from '@libs/Navigation/helpers/resetPolicyIDInNavigationState'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; @@ -189,7 +190,14 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa shouldShowNonAdmin icon={Illustrations.Building} shouldShowNotFoundPage={policy === undefined} - onBackButtonPress={() => Navigation.goBack(backTo)} + onBackButtonPress={() => { + if (backTo) { + Navigation.goBack(backTo); + return; + } + + goBackFromWorkspaceCentralScreen(policy?.id); + }} > {(hasVBA?: boolean) => ( diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 166d9ff20106..248bbb0274e0 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -16,6 +16,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import {openWorkspaceView} from '@libs/actions/BankAccounts'; import BankAccount from '@libs/models/BankAccount'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import {isPendingDeletePolicy, isPolicyAdmin, shouldShowPolicy as shouldShowPolicyUtil} from '@libs/PolicyUtils'; import CONST from '@src/CONST'; @@ -161,6 +162,20 @@ function WorkspacePageWithSections({ // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [policy, shouldShowNonAdmin, shouldShowPolicy]); + const handleOnBackButtonPress = () => { + if (onBackButtonPress) { + onBackButtonPress(); + return; + } + + if (backButtonRoute) { + Navigation.goBack(backButtonRoute); + return; + } + + goBackFromWorkspaceCentralScreen(policyID); + }; + return ( (onBackButtonPress ? onBackButtonPress() : Navigation.goBack(backButtonRoute))} + onBackButtonPress={handleOnBackButtonPress} shouldShowBackButton={shouldUseNarrowLayout || shouldShowBackButton} icon={icon ?? undefined} style={styles.headerBarDesktopHeight} diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 7d5ea22ba3a3..5255e15e5332 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -32,6 +32,7 @@ import {isAuthenticationError, isConnectionInProgress, isConnectionUnverified, r import {shouldShowQBOReimbursableExportDestinationAccountError} from '@libs/actions/connections/QuickbooksOnline'; import {getAssignedSupportData} from '@libs/actions/Policy/Policy'; import {isExpensifyCardFullySetUp} from '@libs/CardUtils'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import { areSettingsInErrorFields, findCurrentXeroOrganization, @@ -534,6 +535,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { icon={Illustrations.Accounting} shouldUseHeadlineHeader threeDotsAnchorPosition={threeDotsAnchorPosition} + onBackButtonPress={() => goBackFromWorkspaceCentralScreen(policyID)} /> diff --git a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx index 3c807548c749..4acda8f8585c 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx @@ -38,6 +38,7 @@ import {isConnectionInProgress} from '@libs/actions/connections'; import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import localeCompare from '@libs/LocaleCompare'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types'; @@ -417,7 +418,13 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { turnOffMobileSelectionMode(); return; } - Navigation.goBack(backTo); + + if (backTo) { + Navigation.goBack(backTo); + return; + } + + goBackFromWorkspaceCentralScreen(policyId); }} shouldShowThreeDotsButton style={styles.headerBarDesktopHeight} diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx index 313f4ebdc115..ff76b017df64 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx @@ -32,6 +32,7 @@ import { } from '@libs/actions/Policy/DistanceRate'; import {convertAmountToDisplayString} from '@libs/CurrencyUtils'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import {getDistanceRateCustomUnit} from '@libs/PolicyUtils'; @@ -356,7 +357,7 @@ function PolicyDistanceRatesPage({ turnOffMobileSelectionMode(); return; } - Navigation.goBack(); + goBackFromWorkspaceCentralScreen(policyID); }} > {!shouldUseNarrowLayout && headerButtons} diff --git a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx index e742dbbdcce8..efa5494fbaed 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx @@ -11,6 +11,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import useWorkspaceAccountID from '@hooks/useWorkspaceAccountID'; import {getLastFourDigits} from '@libs/BankAccountUtils'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import Navigation from '@navigation/Navigation'; import type {SettingsNavigatorParamList} from '@navigation/types'; @@ -48,7 +49,10 @@ function WorkspaceCardSettingsPage({route}: WorkspaceCardSettingsPageProps) { includeSafeAreaPaddingBottom={false} shouldEnableMaxHeight > - + goBackFromWorkspaceCentralScreen(policyID)} + /> diff --git a/src/pages/workspace/perDiem/WorkspacePerDiemPage.tsx b/src/pages/workspace/perDiem/WorkspacePerDiemPage.tsx index 2e6fe81538aa..bd81432ba26d 100644 --- a/src/pages/workspace/perDiem/WorkspacePerDiemPage.tsx +++ b/src/pages/workspace/perDiem/WorkspacePerDiemPage.tsx @@ -34,6 +34,7 @@ import useThreeDotsAnchorPosition from '@hooks/useThreeDotsAnchorPosition'; import {convertAmountToDisplayString} from '@libs/CurrencyUtils'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import localeCompare from '@libs/LocaleCompare'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types'; @@ -382,7 +383,13 @@ function WorkspacePerDiemPage({route}: WorkspacePerDiemPageProps) { turnOffMobileSelectionMode(); return; } - Navigation.goBack(backTo); + + if (backTo) { + Navigation.goBack(backTo); + return; + } + + goBackFromWorkspaceCentralScreen(policyID); }} shouldShowThreeDotsButton threeDotsMenuItems={threeDotsMenuItems} diff --git a/src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx b/src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx index 90a3f0a41438..90f85bc7afae 100644 --- a/src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx +++ b/src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx @@ -35,6 +35,7 @@ import {isConnectionInProgress} from '@libs/actions/connections'; import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import localeCompare from '@libs/LocaleCompare'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types'; @@ -256,7 +257,7 @@ function WorkspaceReportFieldsPage({ turnOffMobileSelectionMode(); return; } - Navigation.goBack(); + goBackFromWorkspaceCentralScreen(policyID); }} > {!shouldUseNarrowLayout && !hasReportAccountingConnections && getHeaderButtons()} diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index f90d856d9aec..9f37f44417b0 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -38,6 +38,7 @@ import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode'; import {clearPolicyTagErrors, deletePolicyTags, downloadTagsCSV, openPolicyTagsPage, setPolicyTagsRequired, setWorkspaceTagEnabled} from '@libs/actions/Policy/Tag'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import localeCompare from '@libs/LocaleCompare'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types'; @@ -452,7 +453,13 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { turnOffMobileSelectionMode(); return; } - Navigation.goBack(backTo); + + if (backTo) { + Navigation.goBack(backTo); + return; + } + + goBackFromWorkspaceCentralScreen(policyID); }} shouldShowThreeDotsButton={!policy?.hasMultipleTagLists} threeDotsMenuItems={threeDotsMenuItems} diff --git a/src/pages/workspace/taxes/WorkspaceTaxesPage.tsx b/src/pages/workspace/taxes/WorkspaceTaxesPage.tsx index 0e41e3844e28..3bb5dc89ea01 100644 --- a/src/pages/workspace/taxes/WorkspaceTaxesPage.tsx +++ b/src/pages/workspace/taxes/WorkspaceTaxesPage.tsx @@ -30,6 +30,7 @@ import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode'; import {clearTaxRateError, deletePolicyTaxes, setPolicyTaxesEnabled} from '@libs/actions/TaxRate'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import {getLatestErrorFieldForAnyField} from '@libs/ErrorUtils'; +import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import {canEditTaxRate as canEditTaxRatePolicyUtils, getCurrentConnectionName, hasAccountingConnections as hasAccountingConnectionsPolicyUtils, shouldShowSyncError} from '@libs/PolicyUtils'; @@ -355,7 +356,7 @@ function WorkspaceTaxesPage({ turnOffMobileSelectionMode(); return; } - Navigation.goBack(); + goBackFromWorkspaceCentralScreen(policyID); }} > {!shouldUseNarrowLayout && headerButtons}