Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9f10acc
Add RBR/GBR chat and Account switcher tooltips
rayane-d Mar 17, 2025
ebe2e56
prettier
rayane-d Mar 17, 2025
04608cb
correct comment
rayane-d Mar 17, 2025
a03d032
disable concierge tooltip
rayane-d Mar 17, 2025
467f51e
fix test
rayane-d Mar 17, 2025
43aeacc
hide account switcher tooltip when the settings page is not focused
rayane-d Mar 18, 2025
aa847ae
prettier
rayane-d Mar 18, 2025
cf6afe3
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Mar 23, 2025
28cb984
revert a change
rayane-d Mar 24, 2025
f25fa90
Add close button changes
rayane-d Mar 24, 2025
38274da
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Mar 24, 2025
f9c95e5
lint
rayane-d Mar 24, 2025
8b1d153
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Mar 30, 2025
4e3bfe7
Enhance tooltip alignment logic
rayane-d Mar 30, 2025
92062a1
fix lint
rayane-d Mar 31, 2025
0c2a2d8
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Apr 15, 2025
e839812
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Apr 22, 2025
ccaf45e
update translations
rayane-d Apr 23, 2025
461c2f1
Fix conflict
rayane-d Apr 23, 2025
cdc1916
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Apr 23, 2025
e800c42
correct type
rayane-d Apr 23, 2025
d67e5a7
prettier
rayane-d Apr 23, 2025
244ad46
fix Changed files ESLint check errors
rayane-d Apr 23, 2025
50ab699
fix: remove syntax error in useOnyx for allCards
rayane-d Apr 23, 2025
79d6779
refactor tooltip rendering in AccountSwitcher component
rayane-d Apr 23, 2025
b194459
move onPressSwitcher function
rayane-d Apr 23, 2025
b2711ba
remove unecessary comment
rayane-d Apr 23, 2025
2c31346
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Apr 28, 2025
32d0991
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Apr 30, 2025
e6142ec
Merge branch 'main' into Add-RBRorGBR-and-Account-switcher-tooltips
rayane-d Apr 30, 2025
a4edee2
fix lint errors
rayane-d May 1, 2025
66700b0
Fix bug
rayane-d May 1, 2025
4b5c64b
fix bug
rayane-d May 1, 2025
102d131
fix lint
rayane-d May 1, 2025
144e62a
fix spelling
rayane-d May 1, 2025
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: 2 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6991,6 +6991,8 @@ const CONST = {
SCAN_TEST_TOOLTIP: 'scanTestTooltip',
SCAN_TEST_TOOLTIP_MANAGER: 'scanTestTooltipManager',
SCAN_TEST_CONFIRMATION: 'scanTestConfirmation',
GBR_RBR_CHAT: 'chatGBRRBR',
ACCOUNT_SWITCHER: 'accountSwitcher',
EXPENSE_REPORTS_FILTER: 'expenseReportsFilter',
},
CHANGE_POLICY_TRAINING_MODAL: 'changePolicyModal',
Expand Down
59 changes: 46 additions & 13 deletions src/components/AccountSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ import * as Expensicons from './Icon/Expensicons';
import type {PopoverMenuItem} from './PopoverMenu';
import PopoverMenu from './PopoverMenu';
import {PressableWithFeedback} from './Pressable';
import {useProductTrainingContext} from './ProductTrainingContext';
import Text from './Text';
import Tooltip from './Tooltip';
import EducationalTooltip from './Tooltip/EducationalTooltip';

function AccountSwitcher() {
type AccountSwitcherProps = {
/* Whether the screen is focused. Used to hide the product training tooltip */
isScreenFocused: boolean;
};

function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const styles = useThemeStyles();
const theme = useTheme();
Expand All @@ -47,10 +54,42 @@ function AccountSwitcher() {
const [shouldShowOfflineModal, setShouldShowOfflineModal] = useState(false);
const delegators = account?.delegatedAccess?.delegators ?? [];

const isActingAsDelegate = !!account?.delegatedAccess?.delegate ?? false;
const isActingAsDelegate = !!account?.delegatedAccess?.delegate;
const canSwitchAccounts = delegators.length > 0 || isActingAsDelegate;
const accountSwitcherPopoverStyle = canUseLeftHandBar ? styles.accountSwitcherPopoverWithLHB : styles.accountSwitcherPopover;

const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.ACCOUNT_SWITCHER,
isScreenFocused && canSwitchAccounts,
);

const onPressSwitcher = () => {
hideProductTrainingTooltip();
setShouldShowDelegatorMenu(!shouldShowDelegatorMenu);
};

const TooltipToRender = shouldShowProductTrainingTooltip ? EducationalTooltip : Tooltip;
const tooltipProps = shouldShowProductTrainingTooltip
? {
shouldRender: shouldShowProductTrainingTooltip,
renderTooltipContent: renderProductTrainingTooltip,
anchorAlignment: {
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
},
shiftVertical: variables.accountSwitcherTooltipShiftVertical,
shiftHorizontal: variables.accountSwitcherTooltipShiftHorizontal,
wrapperStyle: styles.productTrainingTooltipWrapper,
onTooltipPress: onPressSwitcher,
}
: {
text: translate('delegate.copilotAccess'),
shiftVertical: 8,
shiftHorizontal: 8,
anchorAlignment: {horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM},
shouldRender: canSwitchAccounts,
};

const createBaseMenuItem = (
personalDetails: PersonalDetails | undefined,
errors?: Errors,
Expand Down Expand Up @@ -133,19 +172,12 @@ function AccountSwitcher() {

return (
<>
<Tooltip
text={translate('delegate.copilotAccess')}
shiftVertical={8}
shiftHorizontal={8}
anchorAlignment={{horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM}}
shouldRender={canSwitchAccounts}
>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
<TooltipToRender {...tooltipProps}>
<PressableWithFeedback
accessible
accessibilityLabel={translate('common.profile')}
onPress={() => {
setShouldShowDelegatorMenu(!shouldShowDelegatorMenu);
}}
onPress={onPressSwitcher}
ref={buttonRef}
interactive={canSwitchAccounts}
pressDimmingValue={canSwitchAccounts ? undefined : 1}
Expand Down Expand Up @@ -195,7 +227,8 @@ function AccountSwitcher() {
</View>
</View>
</PressableWithFeedback>
</Tooltip>
</TooltipToRender>

{!!canSwitchAccounts && (
<PopoverMenu
isVisible={shouldShowDelegatorMenu}
Expand Down
30 changes: 28 additions & 2 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import BlockingView from '@components/BlockingViews/BlockingView';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import LottieAnimations from '@components/LottieAnimations';
import {useProductTrainingContext} from '@components/ProductTrainingContext';
import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider';
import TextBlock from '@components/TextBlock';
import useLHNEstimatedListSize from '@hooks/useLHNEstimatedListSize';
Expand All @@ -21,9 +22,9 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {isValidDraftComment} from '@libs/DraftCommentUtils';
import getPlatform from '@libs/getPlatform';
import Log from '@libs/Log';
import {getIOUReportIDOfLastAction, getLastMessageTextForReport} from '@libs/OptionsListUtils';
import {getIOUReportIDOfLastAction, getLastMessageTextForReport, hasReportErrors} from '@libs/OptionsListUtils';
import {getOneTransactionThreadReportID, getOriginalMessage, getSortedReportActionsForDisplay, isMoneyRequestAction} from '@libs/ReportActionsUtils';
import {canUserPerformWriteAction} from '@libs/ReportUtils';
import {canUserPerformWriteAction, requiresAttentionFromCurrentUser} from '@libs/ReportUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -59,6 +60,27 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
const platform = getPlatform();
const isWebOrDesktop = platform === CONST.PLATFORM.WEB || platform === CONST.PLATFORM.DESKTOP;

const {shouldShowProductTrainingTooltip} = useProductTrainingContext(CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GBR_RBR_CHAT, true);
const firstReportIDWithGBRorRBR = useMemo(() => {
if (!shouldShowProductTrainingTooltip) {
return undefined;
}
return data.find((reportID) => {
const itemFullReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const itemReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`];
if (!itemFullReport) {
return false;
}
if (hasReportErrors(itemFullReport, itemReportActions)) {
return true;
}
const itemParentReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${itemFullReport?.parentReportID}`];
const itemParentReportAction = itemFullReport?.parentReportActionID ? itemParentReportActions?.[itemFullReport?.parentReportActionID] : undefined;
const hasGBR = requiresAttentionFromCurrentUser(itemFullReport, itemParentReportAction);
return hasGBR;
});
}, [shouldShowProductTrainingTooltip, data, reportActions, reports]);

// When the first item renders we want to call the onFirstItemRendered callback.
// At this point in time we know that the list is actually displaying items.
const hasCalledOnLayout = React.useRef(false);
Expand Down Expand Up @@ -181,6 +203,8 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
}
const lastMessageTextFromReport = getLastMessageTextForReport(itemFullReport, lastActorDetails, itemPolicy, itemReportNameValuePairs);

const shouldShowRBRorGBRTooltip = firstReportIDWithGBRorRBR === reportID;

return (
<OptionRowLHNData
reportID={reportID}
Expand All @@ -205,6 +229,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
hasDraftComment={hasDraftComment}
transactionViolations={transactionViolations}
onLayout={onLayoutItem}
shouldShowRBRorGBRTooltip={shouldShowRBRorGBRTooltip}
/>
);
},
Expand All @@ -224,6 +249,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
transactionViolations,
onLayoutItem,
isOffline,
firstReportIDWithGBRorRBR,
],
);

Expand Down
46 changes: 33 additions & 13 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import {useSession} from '@components/OnyxProvider';
import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction';
import {useProductTrainingContext} from '@components/ProductTrainingContext';
import type {ProductTrainingTooltipName} from '@components/ProductTrainingContext/TOOLTIPS';
import SubscriptAvatar from '@components/SubscriptAvatar';
import Text from '@components/Text';
import Tooltip from '@components/Tooltip';
Expand Down Expand Up @@ -49,18 +50,28 @@ import ONYXKEYS from '@src/ONYXKEYS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type {OptionRowLHNProps} from './types';

function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, optionItem, viewMode = 'default', style, onLayout = () => {}, hasDraftComment}: OptionRowLHNProps) {
function OptionRowLHN({
reportID,
isFocused = false,
onSelectRow = () => {},
optionItem,
viewMode = 'default',
style,
onLayout = () => {},
hasDraftComment,
shouldShowRBRorGBRTooltip,
}: OptionRowLHNProps) {
const theme = useTheme();
const styles = useThemeStyles();
const popoverAnchor = useRef<View>(null);
const StyleUtils = useStyleUtils();
const [isScreenFocused, setIsScreenFocused] = useState(false);
const {shouldUseNarrowLayout} = useResponsiveLayout();

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID}`);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [isFullscreenVisible] = useOnyx(ONYXKEYS.FULLSCREEN_VISIBILITY);
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID}`, {canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});
const [isFullscreenVisible] = useOnyx(ONYXKEYS.FULLSCREEN_VISIBILITY, {canBeMissing: true});
const session = useSession();
const shouldShowWorkspaceChatTooltip = isPolicyExpenseChat(report) && !isThread(report) && activePolicyID === report?.policyID && session?.accountID === report?.ownerAccountID;
const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+');
Expand All @@ -69,16 +80,25 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti

const isReportsSplitNavigatorLast = useRootNavigationState((state) => state?.routes?.at(-1)?.name === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR);

const {tooltipToRender, shouldShowTooltip} = useMemo(() => {
const {tooltipToRender, shouldShowTooltip, shouldTooltipBeLeftAligned} = useMemo(() => {
// TODO: CONCIERGE_LHN_GBR tooltip will be replaced by a tooltip in the #admins room
// https://github.com/Expensify/App/issues/57045#issuecomment-2701455668
const tooltip = shouldShowGetStartedTooltip ? CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.CONCIERGE_LHN_GBR : CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.LHN_WORKSPACE_CHAT_TOOLTIP;
const shouldShowTooltips = shouldShowWorkspaceChatTooltip || shouldShowGetStartedTooltip;
let tooltip: ProductTrainingTooltipName = shouldShowGetStartedTooltip
? CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.CONCIERGE_LHN_GBR
: CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.LHN_WORKSPACE_CHAT_TOOLTIP;
if (shouldShowRBRorGBRTooltip) {
tooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GBR_RBR_CHAT;
}
const shouldShowTooltips = shouldShowRBRorGBRTooltip || shouldShowWorkspaceChatTooltip || shouldShowGetStartedTooltip;
const shouldTooltipBeVisible = shouldUseNarrowLayout ? isScreenFocused && isReportsSplitNavigatorLast : isReportsSplitNavigatorLast && !isFullscreenVisible;

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
return {tooltipToRender: tooltip, shouldShowTooltip: shouldShowTooltips && shouldTooltipBeVisible};
}, [shouldShowGetStartedTooltip, shouldShowWorkspaceChatTooltip, isScreenFocused, shouldUseNarrowLayout, isReportsSplitNavigatorLast, isFullscreenVisible]);
return {
tooltipToRender: tooltip,
shouldShowTooltip: shouldShowTooltips && shouldTooltipBeVisible,
shouldTooltipBeLeftAligned: shouldShowWorkspaceChatTooltip && !shouldShowRBRorGBRTooltip && !shouldShowGetStartedTooltip,
};
}, [shouldShowRBRorGBRTooltip, shouldShowGetStartedTooltip, shouldShowWorkspaceChatTooltip, isScreenFocused, shouldUseNarrowLayout, isReportsSplitNavigatorLast, isFullscreenVisible]);

const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(tooltipToRender, shouldShowTooltip);

Expand Down Expand Up @@ -195,11 +215,11 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
shouldRender={shouldShowProductTrainingTooltip}
renderTooltipContent={renderProductTrainingTooltip}
anchorAlignment={{
horizontal: shouldShowWorkspaceChatTooltip ? CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT : CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
horizontal: shouldTooltipBeLeftAligned ? CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT : CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
}}
shiftHorizontal={shouldShowWorkspaceChatTooltip ? variables.workspaceLHNTooltipShiftHorizontal : variables.gbrTooltipShiftHorizontal}
shiftVertical={shouldShowWorkspaceChatTooltip ? 0 : variables.gbrTooltipShiftVertical}
shiftHorizontal={shouldTooltipBeLeftAligned ? variables.workspaceLHNTooltipShiftHorizontal : variables.gbrTooltipShiftHorizontal}
shiftVertical={shouldTooltipBeLeftAligned ? 0 : variables.gbrTooltipShiftVertical}
wrapperStyle={styles.productTrainingTooltipWrapper}
onTooltipPress={onOptionPress}
shouldHideOnScroll
Expand Down
6 changes: 6 additions & 0 deletions src/components/LHNOptionsList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ type OptionRowLHNDataProps = {

/** Callback to execute when the OptionList lays out */
onLayout?: (event: LayoutChangeEvent) => void;

/** Whether to show the educational tooltip for the GBR or RBR */
shouldShowRBRorGBRTooltip: boolean;
};

type OptionRowLHNProps = {
Expand All @@ -141,6 +144,9 @@ type OptionRowLHNProps = {
hasDraftComment: boolean;

onLayout?: (event: LayoutChangeEvent) => void;

/** Whether to show the educational tooltip on the GBR or RBR */
shouldShowRBRorGBRTooltip: boolean;
};

type RenderItemProps = {item: string};
Expand Down
25 changes: 25 additions & 0 deletions src/components/ProductTrainingContext/TOOLTIPS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const {
SCAN_TEST_TOOLTIP,
SCAN_TEST_TOOLTIP_MANAGER,
SCAN_TEST_CONFIRMATION,
GBR_RBR_CHAT,
ACCOUNT_SWITCHER,
EXPENSE_REPORTS_FILTER,
} = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES;

Expand Down Expand Up @@ -90,6 +92,29 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
priority: 1800,
shouldShow: ({isUserPolicyEmployee}) => isUserPolicyEmployee,
},
[GBR_RBR_CHAT]: {
content: [
{text: 'productTrainingTooltip.GBRRBRChat.part1', isBold: false},
{text: 'productTrainingTooltip.GBRRBRChat.part2', isBold: true},
{text: 'productTrainingTooltip.GBRRBRChat.part3', isBold: false},
{text: 'productTrainingTooltip.GBRRBRChat.part4', isBold: true},
],
onHideTooltip: () => dismissProductTraining(GBR_RBR_CHAT),
name: GBR_RBR_CHAT,
priority: 1900,
shouldShow: () => true,
},
[ACCOUNT_SWITCHER]: {
content: [
{text: 'productTrainingTooltip.accountSwitcher.part1', isBold: false},
{text: 'productTrainingTooltip.accountSwitcher.part2', isBold: true},
{text: 'productTrainingTooltip.accountSwitcher.part3', isBold: false},
],
onHideTooltip: () => dismissProductTraining(ACCOUNT_SWITCHER),
name: ACCOUNT_SWITCHER,
priority: 1600,
shouldShow: () => true,
},
[EXPENSE_REPORTS_FILTER]: {
content: [
{text: 'productTrainingTooltip.expenseReportsFilter.part1', isBold: false},
Expand Down
11 changes: 11 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6227,6 +6227,17 @@ const translations = {
part3: '\nand more.',
part4: ' Try it out!',
},
GBRRBRChat: {
part1: 'You’ll see 🟢 on ',
part2: 'actions to take',
part3: ',\nand 🔴 on ',
part4: 'errors to review.',
},
accountSwitcher: {
part1: 'Access your ',
part2: 'Copilot accounts',
part3: ' here',
},
expenseReportsFilter: {
part1: 'Welcome! Find all of your',
part2: "\ncompany's reports",
Expand Down
11 changes: 11 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6752,6 +6752,17 @@ const translations = {
part3: '\ny más.',
part4: ' ¡Pruébalo!',
},
GBRRBRChat: {
part1: 'Verás 🟢 en ',
part2: 'las acciones a realizar',
part3: '\ny 🔴 en ',
part4: 'los errores que debes revisar.',
},
accountSwitcher: {
part1: 'Accede a tus ',
part2: 'cuentas copiloto',
part3: ' aquí',
},
expenseReportsFilter: {
part1: '¡Bienvenido! Aquí encontrarás todos los',
part2: '\ninformes de tu empresa',
Expand Down
16 changes: 16 additions & 0 deletions src/libs/Navigation/helpers/useRouteActive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {findFocusedRoute, useNavigationState} from '@react-navigation/native';
import useRootNavigationState from '@hooks/useRootNavigationState';
import NAVIGATORS from '@src/NAVIGATORS';
import SCREENS from '@src/SCREENS';

function useIsAccountSettingsRouteActive(isNarrowLayout: boolean) {
const focusedRoute = useNavigationState(findFocusedRoute);
const navigationState = useRootNavigationState((x) => x);

const isSettingsSplitNavigator = navigationState?.routes.at(-1)?.name === NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR;
const isAccountSettings = focusedRoute?.name === SCREENS.SETTINGS.ROOT;

return isNarrowLayout ? isAccountSettings && isSettingsSplitNavigator : isSettingsSplitNavigator;
}

export default useIsAccountSettingsRouteActive;
Loading
Loading