Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1431,8 +1431,6 @@ const CONST = {
ARCHIVE_POLICIES: 'archivePolicies',
MERGE_ATS: 'mergeATSConnections',
REPORT_MERGE: 'reportMerge',
INSIGHTS_PAGE: 'insightsPage',
INSIGHTS_COMPARE: 'insightsCompare',
NL_FILTERS: 'nlFilters',
PAYMENT_HISTORY: 'paymentHistory',
UNIFIED_CONNECTIONS: 'unifiedConnections',
Expand Down
4 changes: 1 addition & 3 deletions src/components/Navigation/AccountAvatarButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import EducationalTooltip from '@components/Tooltip/EducationalTooltip';
import useAccountTabIndicatorStatus from '@hooks/useAccountTabIndicatorStatus';
import useIsAnonymousUser from '@hooks/useIsAnonymousUser';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';

Expand All @@ -28,10 +27,9 @@ import React from 'react';
* the Account tab is not part of the navigation tab bar.
*/
function AccountAvatarButton() {
const {isBetaEnabled} = usePermissions();
const {shouldUseNarrowLayout} = useResponsiveLayout();

if (!shouldUseNarrowLayout || !isBetaEnabled(CONST.BETAS.INSIGHTS_PAGE)) {
if (!shouldUseNarrowLayout) {
return null;
}

Expand Down
30 changes: 8 additions & 22 deletions src/components/Navigation/NavigationTabBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {PressableWithFeedback} from '@components/Pressable';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -45,8 +44,6 @@ function NavigationTabBar({selectedTab, shouldShowFloatingButtons = true}: Navig
const styles = useThemeStyles();
const {translate} = useLocalize();
const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED);
const {isBetaEnabled} = usePermissions();
const isInsightsTabVisible = isBetaEnabled(CONST.BETAS.INSIGHTS_PAGE);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['ExpensifyAppIcon', 'Home']);

const {shouldUseNarrowLayout} = useResponsiveLayout();
Expand Down Expand Up @@ -123,12 +120,10 @@ function NavigationTabBar({selectedTab, shouldShowFloatingButtons = true}: Navig
selectedTab={selectedTab}
isWideLayout
/>
{isInsightsTabVisible && (
<InsightsTabButton
selectedTab={selectedTab}
isWideLayout
/>
)}
<InsightsTabButton
selectedTab={selectedTab}
isWideLayout
/>
<WorkspacesTabButton
selectedTab={selectedTab}
isWideLayout
Expand Down Expand Up @@ -180,23 +175,14 @@ function NavigationTabBar({selectedTab, shouldShowFloatingButtons = true}: Navig
selectedTab={selectedTab}
isWideLayout={false}
/>
{isInsightsTabVisible && (
<InsightsTabButton
selectedTab={selectedTab}
isWideLayout={false}
/>
)}
<InsightsTabButton
selectedTab={selectedTab}
isWideLayout={false}
/>
<WorkspacesTabButton
selectedTab={selectedTab}
isWideLayout={false}
/>
{!isInsightsTabVisible && (
<NavigationTabBarAvatar
style={styles.navigationTabBarItem}
isSelected={selectedTab === NAVIGATION_TABS.SETTINGS}
onPress={navigateToSettings}
/>
)}
</View>

{shouldShowFloatingButtons && (
Expand Down
22 changes: 8 additions & 14 deletions src/components/Search/SearchRouter/useNavigationSuggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ type BuildTopLevelNavigationItemsParams = {
account: string;
};
icons: TopLevelNavigationIcons;
isInsightsPageBetaEnabled: boolean;
getSpendRoute: () => Route;
getDestinationText: (destination: string) => string;
};
Expand Down Expand Up @@ -219,7 +218,7 @@ type BuildAccountNavigationItemsParams = {
};

// Tab buttons own stateful navigation behavior and do not expose reusable descriptors, so Search Router keeps deterministic destination actions here.
function buildTopLevelNavigationItems({labels, icons, isInsightsPageBetaEnabled, getSpendRoute, getDestinationText}: BuildTopLevelNavigationItemsParams): NavigationSuggestionSourceItem[] {
function buildTopLevelNavigationItems({labels, icons, getSpendRoute, getDestinationText}: BuildTopLevelNavigationItemsParams): NavigationSuggestionSourceItem[] {
return [
{
text: getDestinationText(labels.home),
Expand All @@ -242,17 +241,13 @@ function buildTopLevelNavigationItems({labels, icons, isInsightsPageBetaEnabled,
keyForList: 'topLevelSpend',
matchTerms: [labels.spend],
},
...(isInsightsPageBetaEnabled
? [
{
text: getDestinationText(labels.insights),
singleIcon: icons.PieChart,
action: () => Navigation.navigate(ROUTES.INSIGHTS.getRoute(CONST.INSIGHTS.DASHBOARD.SPEND)),
keyForList: 'topLevelInsights',
matchTerms: [labels.insights],
},
]
: []),
{
text: getDestinationText(labels.insights),
singleIcon: icons.PieChart,
action: () => Navigation.navigate(ROUTES.INSIGHTS.getRoute(CONST.INSIGHTS.DASHBOARD.SPEND)),
keyForList: 'topLevelInsights',
matchTerms: [labels.insights],
},
{
text: getDestinationText(labels.workspaces),
singleIcon: icons.Building,
Expand Down Expand Up @@ -434,7 +429,6 @@ function useNavigationSuggestions(query: string, shouldWatchForApprovals = true)
account: translate('initialSettingsPage.account'),
},
icons,
isInsightsPageBetaEnabled: isBetaEnabled(CONST.BETAS.INSIGHTS_PAGE),
getSpendRoute: () => getSearchTabRoute(navigationRef.getRootState(), lastSearchParams, lastExpensesSearchQuerySelector(searchFilters)),
getDestinationText: (destination) => getGoToText(translate, destination),
});
Expand Down
9 changes: 1 addition & 8 deletions src/hooks/useIsSettingsDrawnOverTabs/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';

import getTabWithoutBarItem from '@libs/Navigation/AppNavigator/Navigators/NativeTabNavigator/getTabWithoutBarItem';

import CONST from '@src/CONST';
import NAVIGATORS from '@src/NAVIGATORS';

/**
* When the native tab bar has no Account item, the Account tab is drawn over the other tabs
* as a full screen with the bar hidden, and it needs its own way back.
*/
function useIsSettingsDrawnOverTabs() {
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {isBetaEnabled} = usePermissions();
return shouldUseNarrowLayout && getTabWithoutBarItem(isBetaEnabled(CONST.BETAS.INSIGHTS_PAGE)) === NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR;
return shouldUseNarrowLayout;
}

export default useIsSettingsDrawnOverTabs;
4 changes: 0 additions & 4 deletions src/hooks/useSearchTypeMenuSections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ const useSearchTypeMenuSectionsForNavigation = (isScreenFocused = true) => {
sections = omitTravelApprovalMenuItems(sections);
}

if (!isBetaEnabled(CONST.BETAS.INSIGHTS_PAGE)) {
return sections;
}

return omitInsightsPageMenuItems(sections);
};

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ import useAccountTabIndicatorStatus from '@hooks/useAccountTabIndicatorStatus';
import useInboxTabIndicatorStatus from '@hooks/useInboxTabIndicatorStatus';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useWorkspacesTabIndicatorStatus from '@hooks/useWorkspacesTabIndicatorStatus';

import {getPreservedNavigatorState, setPreservedNavigatorState} from '@libs/Navigation/AppNavigator/createSplitNavigator/usePreserveNavigatorState';
import isTabRouteAtRoot from '@libs/Navigation/helpers/isTabRouteAtRoot';
import Navigation from '@libs/Navigation/Navigation';
import type {TabNavigatorParamList} from '@libs/Navigation/types';

import CONST from '@src/CONST';
import NAVIGATORS from '@src/NAVIGATORS';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';

import type {NavigationAction, NavigationState, PartialState, Router, TabNavigationState} from '@react-navigation/native';
Expand All @@ -26,7 +22,6 @@ import {isAnonymousSessionSelector} from '@selectors/Session';
import {useEffect} from 'react';

import getActiveTabRoute from './getActiveTabRoute';
import getTabWithoutBarItem from './getTabWithoutBarItem';
import {isInboxTabAtChatList, isNativeTabSelectionEnabled} from './tabScreenListeners';
import useIsWorkspacesTabRestored from './useIsWorkspacesTabRestored';

Expand All @@ -45,11 +40,9 @@ function isRealizedNavigationState(state: NavigationState | PartialState<Navigat
function useNativeTabNavigator() {
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {isBlockingViewVisible} = useFullScreenBlockingViewState();
const {isBetaEnabled, isBetaEnabledOrUnknown} = usePermissions();
const {translate} = useLocalize();
const [isAnonymousUser = false] = useOnyx(ONYXKEYS.SESSION, {selector: isAnonymousSessionSelector});
const isInsightsTabVisible = isBetaEnabled(CONST.BETAS.INSIGHTS_PAGE);
const tabWithoutBarItem = getTabWithoutBarItem(isInsightsTabVisible);
const tabWithoutBarItem = NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR;
const {indicatorColor: inboxDotColor} = useInboxTabIndicatorStatus();
const {indicatorColor: workspacesIndicatorColor, status: workspacesIndicatorStatus} = useWorkspacesTabIndicatorStatus();
const {indicatorColor: accountIndicatorColor, status: accountIndicatorStatus} = useAccountTabIndicatorStatus();
Expand Down Expand Up @@ -97,17 +90,6 @@ function useNativeTabNavigator() {
setPreservedNavigatorState(route.key, tabState);
}, [tabState, route.key]);

// Without the beta, Insights has no bar item and its page is not found, so a restored or deep-linked Insights tab
// would be a full screen with no way out. Home replaces it, so going back does not return to it. Betas that are
// still loading are not a missing beta.
const isInsightsTabFocusedWithoutBeta = isBetaEnabledOrUnknown(CONST.BETAS.INSIGHTS_PAGE) === false && activeTabRoute?.name === SCREENS.INSIGHTS;
useEffect(() => {
if (!isInsightsTabFocusedWithoutBeta) {
return;
}
Navigation.navigate(ROUTES.HOME, {forceReplace: true});
}, [isInsightsTabFocusedWithoutBeta]);

// The slicing optimization in useCustomRootStackNavigatorState can unmount and later remount
// this TAB_NAVIGATOR. Without restoration it would default to index 0. We restore the saved
// state by overriding the bottom-tab router's getInitialState, the same pattern SplitRouter
Expand All @@ -121,11 +103,9 @@ function useNativeTabNavigator() {
},
});

const isAccountAvatarShown = shouldUseNarrowLayout && tabWithoutBarItem !== NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR;

const isTabSelectionEnabled = (routeName: string) => isNativeTabSelectionEnabled(routeName, {isAnonymousUser, isInboxAtChatList, isWorkspacesTabRestored});

return {shouldShowNativeTabBar, isAccountAvatarShown, dotColors, tabLabels, tabWithoutBarItem, tabRouterOverride, isTabSelectionEnabled};
return {shouldShowNativeTabBar, isAccountAvatarShown: false, dotColors, tabLabels, tabWithoutBarItem, tabRouterOverride, isTabSelectionEnabled};
}

export default useNativeTabNavigator;
7 changes: 0 additions & 7 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import type {OnyxEntry} from 'react-native-onyx';

import type Environment from './Environment/getEnvironment/types';

import getPlatform from './getPlatform';

/**
* Overrides are a test tool, so they never apply in production.
* Android staging and TestFlight are compiled as production, so only the resolved environment tells a real production
Expand Down Expand Up @@ -40,11 +38,6 @@ function isBetaEnabled(beta: Beta, betas: OnyxEntry<Beta[]>, betaConfiguration:
}
}

// Release desktop web independently while the native navigation fixes roll out.
if ((beta === CONST.BETAS.INSIGHTS_PAGE || beta === CONST.BETAS.INSIGHTS_COMPARE) && getPlatform(true) === CONST.PLATFORM.WEB) {
return true;
}

const hasAllBetasEnabled = canUseAllBetas(betas);
const isFeatureEnabled = !!betas?.includes(beta);

Expand Down
1 change: 0 additions & 1 deletion src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7519,7 +7519,6 @@ export {
createTypeMenuSections,
omitInsightsPageMenuItems,
omitTravelApprovalMenuItems,
SPEND_INSIGHT_KEYS,
formatBadgeText,
getSectionBadgeText,
getItemBadgeText,
Expand Down
8 changes: 2 additions & 6 deletions src/pages/Insights/InsightsDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import useLocalize from '@hooks/useLocalize';
import useMultipleSnapshots from '@hooks/useMultipleSnapshots';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useScrollEventEmitter from '@hooks/useScrollEventEmitter';
import useTheme from '@hooks/useTheme';
Expand Down Expand Up @@ -195,13 +194,10 @@ function InsightsDashboard({dashboardID}: {dashboardID: InsightsDashboardID}) {
const {login} = useCurrentUserPersonalDetails();
const [policies, policiesMetadata] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const {filters, defaultFilters, isResolved, setFilters} = useInsightsFilters(dashboardID);
const {isBetaEnabled} = usePermissions();

const isCompareEnabled = isBetaEnabled(CONST.BETAS.INSIGHTS_COMPARE);
const {headlineChart: headlineSpec, supportingCharts: supportingSpecs} = INSIGHTS_DASHBOARD_SPECS[dashboardID];
const eligibleCharts = getVisibleCharts(supportingSpecs, policies, filters.policyIDs, login);
const eligibleGraphKeys = eligibleCharts.map(({graphKey}) => graphKey).join(',');
const query = isResolved && !isLoadingOnyxValue(policiesMetadata) ? buildInsightsJsonQuery(dashboardID, filters, eligibleCharts, isCompareEnabled) : undefined;
const query = isResolved && !isLoadingOnyxValue(policiesMetadata) ? buildInsightsJsonQuery(dashboardID, filters, eligibleCharts) : undefined;
const hash = query?.hash;

const requestDashboard = () => {
Expand All @@ -221,7 +217,7 @@ function InsightsDashboard({dashboardID}: {dashboardID: InsightsDashboardID}) {
}
onRequestConditionsChanged();
// Leaves out jsonQuery so toggling Compare mode doesn't refetch, since every response covers it. Group by and the eligible charts are listed because the hash leaves them out
}, [dashboardID, hash, filters.groupBy, eligibleGraphKeys, isCompareEnabled, isFocused, isOffline]);
}, [dashboardID, hash, filters.groupBy, eligibleGraphKeys, isFocused, isOffline]);

const [dashboard] = useOnyx(`${ONYXKEYS.COLLECTION.INSIGHTS}${dashboardID}_${hash}`);
// Until the filters and workspaces load, the charts have no query to read data for, so they show their loading state
Expand Down
4 changes: 1 addition & 3 deletions src/pages/Insights/InsightsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import useDocumentTitle from '@hooks/useDocumentTitle';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';

import type {TabNavigatorParamList} from '@libs/Navigation/types';

Expand All @@ -19,12 +18,11 @@ type InsightsPageProps = BottomTabScreenProps<TabNavigatorParamList, typeof SCRE

function InsightsPage({route}: InsightsPageProps) {
const {translate} = useLocalize();
const {isBetaEnabled} = usePermissions();
useDocumentTitle(translate('common.insights'));

const dashboardID = Object.values(CONST.INSIGHTS.DASHBOARD).find((id) => id === route.params?.dashboardID);

if (!isBetaEnabled(CONST.BETAS.INSIGHTS_PAGE) || !dashboardID) {
if (!dashboardID) {
return <NotFoundPage />;
}

Expand Down
14 changes: 4 additions & 10 deletions src/pages/Insights/controls/InsightsPageControls.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import ScrollView from '@components/ScrollView';

import useLayoutSpacing from '@hooks/useLayoutSpacing';
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';

import type {InsightsFilters} from '@pages/Insights/insightsFilters';

import CONST from '@src/CONST';

import React from 'react';
import {View} from 'react-native';

Expand All @@ -31,20 +28,17 @@ function InsightsPageControls({filters, defaultFilters, onChange}: InsightsPageC
const styles = useThemeStyles();
const {pageGutter} = useLayoutSpacing();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {isBetaEnabled} = usePermissions();

const controls = (
<>
<InsightsDateControl
value={filters.date}
onChange={(date) => onChange({date})}
/>
{isBetaEnabled(CONST.BETAS.INSIGHTS_COMPARE) && (
<InsightsCompareControl
value={filters.compare}
onChange={(compare) => onChange({compare})}
/>
)}
<InsightsCompareControl
value={filters.compare}
onChange={(compare) => onChange({compare})}
/>
<InsightsWorkspaceControl
value={filters.policyIDs}
onChange={(policyIDs) => onChange({policyIDs})}
Expand Down
Loading
Loading