Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/Navigation/NavigationTabBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {findFocusedRoute} from '@react-navigation/native';
import React, {memo, useCallback, useEffect, useState} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
Expand All @@ -15,6 +16,7 @@ import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import {useSidebarOrderedReports} from '@hooks/useSidebarOrderedReports';
import useStyleUtils from '@hooks/useStyleUtils';
import useSubscriptionPlan from '@hooks/useSubscriptionPlan';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWorkspacesTabIndicatorStatus from '@hooks/useWorkspacesTabIndicatorStatus';
Expand Down Expand Up @@ -57,6 +59,7 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
const {translate} = useLocalize();
const {indicatorColor: workspacesTabIndicatorColor, status: workspacesTabIndicatorStatus} = useWorkspacesTabIndicatorStatus();
const {orderedReports} = useSidebarOrderedReports();
const subscriptionPlan = useSubscriptionPlan();
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: false});
const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: (value) => value?.reports, canBeMissing: true});
const {shouldUseNarrowLayout} = useResponsiveLayout();
Expand Down Expand Up @@ -126,6 +129,11 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
interceptAnonymousUser(() => {
const settingsTabState = getSettingsTabStateFromSessionStorage();
if (settingsTabState && !shouldUseNarrowLayout) {
const stateRoute = findFocusedRoute(settingsTabState);
if (!subscriptionPlan && stateRoute?.name === SCREENS.SETTINGS.SUBSCRIPTION.ROOT) {
Navigation.navigate(ROUTES.SETTINGS_PROFILE.route);
return;
}
const lastVisitedSettingsRoute = getLastVisitedTabPath(settingsTabState);
if (lastVisitedSettingsRoute) {
Navigation.navigate(lastVisitedSettingsRoute);
Expand All @@ -134,7 +142,7 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
}
Navigation.navigate(ROUTES.SETTINGS);
});
}, [selectedTab, shouldUseNarrowLayout]);
}, [selectedTab, subscriptionPlan, shouldUseNarrowLayout]);

/**
* The settings tab is related to SettingsSplitNavigator and WorkspaceSplitNavigator.
Expand Down