From 21693ae84e0ddab7a68922908ee88aacaf9ac09f Mon Sep 17 00:00:00 2001 From: borys3kk Date: Wed, 29 Apr 2026 16:10:26 +0200 Subject: [PATCH 01/17] potential fix --- src/components/Navigation/DebugTabView.tsx | 98 +++++++++-- .../Navigation/NavigationTabBar/index.tsx | 156 ++++++++---------- .../AppNavigator/Navigators/TabNavigator.tsx | 57 ++++--- tests/ui/BottomTabBarTest.tsx | 56 ++++--- 4 files changed, 213 insertions(+), 154 deletions(-) diff --git a/src/components/Navigation/DebugTabView.tsx b/src/components/Navigation/DebugTabView.tsx index 536998617597..3ab09a6f120d 100644 --- a/src/components/Navigation/DebugTabView.tsx +++ b/src/components/Navigation/DebugTabView.tsx @@ -10,26 +10,54 @@ import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useReportAttributes from '@hooks/useReportAttributes'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useRootNavigationState from '@hooks/useRootNavigationState'; +import useSafeAreaPaddings from '@hooks/useSafeAreaPaddings'; import {useSidebarOrderedReportsState} from '@hooks/useSidebarOrderedReports'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import ROOT_TAB_SCREENS from '@libs/Navigation/AppNavigator/Navigators/ROOT_TAB_SCREENS'; +import getFocusedLeafScreenName from '@libs/Navigation/helpers/getFocusedLeafScreenName'; import Navigation from '@libs/Navigation/Navigation'; import {getRouteForCurrentStep as getReimbursementAccountRouteForCurrentStep} from '@libs/ReimbursementAccountUtils'; -import type {BrickRoad} from '@libs/WorkspacesSettingsUtils'; import {getChatTabBrickRoadReportID} from '@libs/WorkspacesSettingsUtils'; +import variables from '@styles/variables'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; +import NAVIGATORS from '@src/NAVIGATORS'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; +import SCREENS from '@src/SCREENS'; import type {ReimbursementAccount} from '@src/types/onyx'; import type IndicatorStatus from '@src/types/utils/IndicatorStatus'; import NAVIGATION_TABS from './NavigationTabBar/NAVIGATION_TABS'; -type DebugTabViewProps = { - selectedTab?: ValueOf; - chatTabBrickRoad: BrickRoad; +const ROUTE_TO_NAVIGATION_TAB: Record> = { + [SCREENS.HOME]: NAVIGATION_TABS.HOME, + [NAVIGATORS.REPORTS_SPLIT_NAVIGATOR]: NAVIGATION_TABS.INBOX, + [NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR]: NAVIGATION_TABS.SEARCH, + [NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR]: NAVIGATION_TABS.SETTINGS, + [NAVIGATORS.WORKSPACE_NAVIGATOR]: NAVIGATION_TABS.WORKSPACES, +}; + +// Mirrors helpers in TabNavigatorBar — keeps tab-root detection consistent with tab-bar visibility. +const TAB_WRAPPER_NAVIGATORS = new Set([ + NAVIGATORS.REPORTS_SPLIT_NAVIGATOR, + NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR, + NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR, + NAVIGATORS.WORKSPACE_NAVIGATOR, +]); + +const isAtTabRootLevel = (name: string | undefined): boolean => !name || ROOT_TAB_SCREENS.has(name) || TAB_WRAPPER_NAVIGATORS.has(name); + +const getPushTargetLeaf = (params: unknown): string | undefined => { + const p = params as {screen?: unknown; params?: unknown} | undefined; + if (typeof p?.screen !== 'string') { + return undefined; + } + return getPushTargetLeaf(p.params) ?? p.screen; }; function getSettingsMessage(status: IndicatorStatus | undefined): TranslationPaths | undefined { @@ -103,17 +131,35 @@ function getSettingsRoute(status: IndicatorStatus | undefined, reimbursementAcco } } -function DebugTabView({selectedTab, chatTabBrickRoad}: DebugTabViewProps) { +function DebugTabView() { const StyleUtils = useStyleUtils(); const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); + const {shouldUseNarrowLayout} = useResponsiveLayout(); + const {paddingBottom: safeAreaPaddingBottom} = useSafeAreaPaddings(true); + const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED); const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const reportAttributes = useReportAttributes(); const {status, indicatorColor, policyIDWithErrors} = useIndicatorStatus(); - const {orderedReportIDs} = useSidebarOrderedReportsState(); + const {orderedReportIDs, chatTabBrickRoad} = useSidebarOrderedReportsState(); const icons = useMemoizedLazyExpensifyIcons(['DotIndicator']); + const tabRootInfo = useRootNavigationState((rootState) => { + if (!rootState) { + return undefined; + } + const tabRoute = rootState.routes.find((route) => route.name === NAVIGATORS.TAB_NAVIGATOR); + const activeRoute = tabRoute?.state?.routes?.[tabRoute.state.index ?? 0]; + if (!activeRoute) { + return undefined; + } + const isAtRoot = isAtTabRootLevel(getFocusedLeafScreenName(activeRoute.state)) && isAtTabRootLevel(getPushTargetLeaf(activeRoute.params)); + return {tabName: activeRoute.name, isAtRoot}; + }); + + const selectedTab = tabRootInfo ? ROUTE_TO_NAVIGATION_TAB[tabRootInfo.tabName] : undefined; + const message = useMemo((): TranslationPaths | undefined => { if (selectedTab === NAVIGATION_TABS.INBOX) { if (chatTabBrickRoad === CONST.BRICK_ROAD_INDICATOR_STATUS.INFO) { @@ -161,26 +207,42 @@ function DebugTabView({selectedTab, chatTabBrickRoad}: DebugTabViewProps) { } }, [selectedTab, chatTabBrickRoad, orderedReportIDs, reportAttributes, status, reimbursementAccount, policyIDWithErrors]); - if (!([NAVIGATION_TABS.INBOX, NAVIGATION_TABS.SETTINGS, NAVIGATION_TABS.WORKSPACES] as string[]).includes(selectedTab ?? '') || !indicator || !message) { + if ( + !isDebugModeEnabled || + !tabRootInfo || + (shouldUseNarrowLayout && !tabRootInfo.isAtRoot) || + !([NAVIGATION_TABS.INBOX, NAVIGATION_TABS.SETTINGS, NAVIGATION_TABS.WORKSPACES] as string[]).includes(selectedTab ?? '') || + !indicator || + !message + ) { return null; } + const positionStyle = shouldUseNarrowLayout + ? {bottom: variables.bottomTabHeight + safeAreaPaddingBottom, left: 0, right: 0} + : {bottom: 0, left: variables.navigationTabBarSize, width: variables.sideBarWithLHBWidth}; + return ( - - + + + {!!message && {translate(message)}} + +