1+ import { findFocusedRoute } from '@react-navigation/native' ;
12import React , { memo , useCallback , useEffect , useState } from 'react' ;
23import { View } from 'react-native' ;
34import { useOnyx } from 'react-native-onyx' ;
@@ -15,6 +16,7 @@ import useLocalize from '@hooks/useLocalize';
1516import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1617import { useSidebarOrderedReports } from '@hooks/useSidebarOrderedReports' ;
1718import useStyleUtils from '@hooks/useStyleUtils' ;
19+ import useSubscriptionPlan from '@hooks/useSubscriptionPlan' ;
1820import useTheme from '@hooks/useTheme' ;
1921import useThemeStyles from '@hooks/useThemeStyles' ;
2022import useWorkspacesTabIndicatorStatus from '@hooks/useWorkspacesTabIndicatorStatus' ;
@@ -57,6 +59,7 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
5759 const { translate} = useLocalize ( ) ;
5860 const { indicatorColor : workspacesTabIndicatorColor , status : workspacesTabIndicatorStatus } = useWorkspacesTabIndicatorStatus ( ) ;
5961 const { orderedReports} = useSidebarOrderedReports ( ) ;
62+ const subscriptionPlan = useSubscriptionPlan ( ) ;
6063 const [ account ] = useOnyx ( ONYXKEYS . ACCOUNT , { canBeMissing : false } ) ;
6164 const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : ( value ) => value ?. reports , canBeMissing : true } ) ;
6265 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
@@ -126,6 +129,11 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
126129 interceptAnonymousUser ( ( ) => {
127130 const settingsTabState = getSettingsTabStateFromSessionStorage ( ) ;
128131 if ( settingsTabState && ! shouldUseNarrowLayout ) {
132+ const stateRoute = findFocusedRoute ( settingsTabState ) ;
133+ if ( ! subscriptionPlan && stateRoute ?. name === SCREENS . SETTINGS . SUBSCRIPTION . ROOT ) {
134+ Navigation . navigate ( ROUTES . SETTINGS_PROFILE . route ) ;
135+ return ;
136+ }
129137 const lastVisitedSettingsRoute = getLastVisitedTabPath ( settingsTabState ) ;
130138 if ( lastVisitedSettingsRoute ) {
131139 Navigation . navigate ( lastVisitedSettingsRoute ) ;
@@ -134,7 +142,7 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
134142 }
135143 Navigation . navigate ( ROUTES . SETTINGS ) ;
136144 } ) ;
137- } , [ selectedTab , shouldUseNarrowLayout ] ) ;
145+ } , [ selectedTab , subscriptionPlan , shouldUseNarrowLayout ] ) ;
138146
139147 /**
140148 * The settings tab is related to SettingsSplitNavigator and WorkspaceSplitNavigator.
0 commit comments