@@ -16,6 +16,7 @@ import CustomListHeader from '@components/SelectionListWithModal/CustomListHeade
1616import ListItemRightCaretWithLabel from '@components/SelectionListWithModal/ListItemRightCaretWithLabel' ;
1717import Switch from '@components/Switch' ;
1818import useConfirmModal from '@hooks/useConfirmModal' ;
19+ import useDynamicBackPath from '@hooks/useDynamicBackPath' ;
1920import useFilteredSelection from '@hooks/useFilteredSelection' ;
2021import { useMemoizedLazyExpensifyIcons } from '@hooks/useLazyAsset' ;
2122import useLocalize from '@hooks/useLocalize' ;
@@ -48,18 +49,20 @@ import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
4849import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper' ;
4950import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow' ;
5051import CONST from '@src/CONST' ;
51- import ROUTES from '@src/ROUTES' ;
52+ import ROUTES , { DYNAMIC_ROUTES } from '@src/ROUTES' ;
5253import SCREENS from '@src/SCREENS' ;
5354import type { PolicyTag } from '@src/types/onyx' ;
5455import type DeepValueOf from '@src/types/utils/DeepValueOf' ;
5556import type { TagListItem } from './types' ;
5657
5758type WorkspaceViewTagsProps =
5859 | PlatformStackScreenProps < SettingsNavigatorParamList , typeof SCREENS . WORKSPACE . TAG_LIST_VIEW >
59- | PlatformStackScreenProps < SettingsNavigatorParamList , typeof SCREENS . SETTINGS_TAGS . SETTINGS_TAG_LIST_VIEW > ;
60+ | PlatformStackScreenProps < SettingsNavigatorParamList , typeof SCREENS . SETTINGS_TAGS . DYNAMIC_SETTINGS_TAG_LIST_VIEW > ;
6061
6162function WorkspaceViewTagsPage ( { route} : WorkspaceViewTagsProps ) {
62- const { policyID, backTo, orderWeight} = route . params ;
63+ const { policyID, orderWeight : orderWeightParam } = route . params ;
64+ const backTo = 'backTo' in route . params ? route . params . backTo : undefined ;
65+ const orderWeight = Number ( orderWeightParam ) ;
6366
6467 // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout for the small screen selection mode
6568 // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
@@ -77,7 +80,8 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
7780 const hasDependentTags = useMemo ( ( ) => hasDependentTagsPolicyUtils ( policy , policyTags ) , [ policy , policyTags ] ) ;
7881 const isMultiLevelTags = isMultiLevelTagsPolicyUtils ( policyTags ) ;
7982 const currentPolicyTag = policyTags ?. [ currentTagListName ] ;
80- const isQuickSettingsFlow = route . name === SCREENS . SETTINGS_TAGS . SETTINGS_TAG_LIST_VIEW ;
83+ const isQuickSettingsFlow = route . name === SCREENS . SETTINGS_TAGS . DYNAMIC_SETTINGS_TAG_LIST_VIEW ;
84+ const backPath = useDynamicBackPath ( DYNAMIC_ROUTES . SETTINGS_TAG_LIST_VIEW . path ) ;
8185 const fetchTags = useCallback ( ( ) => {
8286 openPolicyTagsPage ( policyID ) ;
8387 } , [ policyID ] ) ;
@@ -108,7 +112,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
108112 onClearSelection : ( ) => {
109113 setSelectedTags ( [ ] ) ;
110114 } ,
111- onNavigationCallBack : ( ) => Navigation . goBack ( isQuickSettingsFlow ? ROUTES . SETTINGS_TAGS_ROOT . getRoute ( policyID ) : undefined ) ,
115+ onNavigationCallBack : ( ) => Navigation . goBack ( isQuickSettingsFlow ? backPath : undefined ) ,
112116 } ) ;
113117
114118 const updateWorkspaceTagEnabled = useCallback (
@@ -364,7 +368,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
364368 turnOffMobileSelectionMode ( ) ;
365369 return ;
366370 }
367- Navigation . goBack ( isQuickSettingsFlow ? ROUTES . SETTINGS_TAGS_ROOT . getRoute ( policyID ) : undefined ) ;
371+ Navigation . goBack ( isQuickSettingsFlow ? backPath : undefined ) ;
368372 } }
369373 >
370374 { ! shouldUseNarrowLayout && getHeaderButtons ( ) }
0 commit comments