@@ -12,14 +12,13 @@ import useReportIsArchived from '@hooks/useReportIsArchived';
1212import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1313import { openWorkspace } from '@libs/actions/Policy/Policy' ;
1414import { isValidMoneyRequestType } from '@libs/IOUUtils' ;
15- import Navigation , { navigationRef } from '@libs/Navigation/Navigation ' ;
16- import type { RootNavigatorParamList , State } from '@libs/Navigation/types ' ;
15+ import goBackFromWorkspaceSettingPages from '@libs/Navigation/helpers/goBackFromWorkspaceSettingPages ' ;
16+ import Navigation from '@libs/Navigation/Navigation ' ;
1717import { canSendInvoice , isControlPolicy , isPaidGroupPolicy , isPolicyAccessible , isPolicyAdmin , isPolicyFeatureEnabled as isPolicyFeatureEnabledUtil } from '@libs/PolicyUtils' ;
1818import { canCreateRequest } from '@libs/ReportUtils' ;
1919import NotFoundPage from '@pages/ErrorPage/NotFoundPage' ;
2020import type { IOUType } from '@src/CONST' ;
2121import CONST from '@src/CONST' ;
22- import NAVIGATORS from '@src/NAVIGATORS' ;
2322import ONYXKEYS from '@src/ONYXKEYS' ;
2423import ROUTES from '@src/ROUTES' ;
2524import SCREENS from '@src/SCREENS' ;
@@ -117,14 +116,7 @@ function PageNotFoundFallback({policyID, fullPageNotFoundViewProps, isFeatureEna
117116 shouldShowOfflineIndicator = { false }
118117 onBackButtonPress = { ( ) => {
119118 if ( isPolicyNotAccessible ) {
120- const rootState = navigationRef . getRootState ( ) as State < RootNavigatorParamList > ;
121- const secondToLastRoute = rootState . routes . at ( - 2 ) ;
122-
123- if ( secondToLastRoute ?. name === NAVIGATORS . REPORTS_SPLIT_NAVIGATOR ) {
124- Navigation . dismissModal ( ) ;
125- } else {
126- Navigation . goBack ( ROUTES . WORKSPACES_LIST . route ) ;
127- }
119+ goBackFromWorkspaceSettingPages ( ) ;
128120 return ;
129121 }
130122 Navigation . goBack ( policyID && ! isMoneyRequest ? ROUTES . WORKSPACE_OVERVIEW . getRoute ( policyID ) : undefined ) ;
0 commit comments