Skip to content

Fix: We show wallet balance badge even for those who haven't enabled Expensify wallet #61888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 14, 2025
Merged
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
26 changes: 5 additions & 21 deletions src/pages/settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr

const isScreenFocused = useIsAccountSettingsRouteActive(shouldUseNarrowLayout);
const isWorkspacesTabSelected = focusedRouteName === SCREENS.SETTINGS.WORKSPACES;
const hasActivatedWallet = ([CONST.WALLET.TIER_NAME.GOLD, CONST.WALLET.TIER_NAME.PLATINUM] as string[]).includes(userWallet?.tierName ?? '');

const {
renderProductTrainingTooltip: renderWorkspaceSettingsTooltip,
Expand Down Expand Up @@ -181,6 +182,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
screenName: SCREENS.SETTINGS.WALLET.ROOT,
brickRoadIndicator: walletBrickRoadIndicator,
action: () => Navigation.navigate(ROUTES.SETTINGS_WALLET),
badgeText: hasActivatedWallet ? convertToDisplayString(userWallet?.currentBalance) : undefined,
},
{
translationKey: 'common.preferences',
Expand All @@ -198,7 +200,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
};

return defaultMenu;
}, [loginList, privatePersonalDetails, styles.accountSettingsSectionContainer, walletBrickRoadIndicator]);
}, [loginList, privatePersonalDetails, styles.accountSettingsSectionContainer, walletBrickRoadIndicator, hasActivatedWallet, userWallet?.currentBalance]);

const navigateToWorkspacesSettings = useCallback(() => {
hideWorkspaceSettingsTooltip();
Expand Down Expand Up @@ -343,12 +345,6 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
*/
const getMenuItemsSection = useCallback(
(menuItemsData: Menu) => {
/**
* @param isPaymentItem whether the item being rendered is the payments menu item
* @returns the user's wallet balance
*/
const getWalletBalance = (isPaymentItem: boolean): string | undefined => (isPaymentItem ? convertToDisplayString(userWallet?.currentBalance) : undefined);

const openPopover = (link: string | (() => Promise<string>) | undefined, event: GestureResponderEvent | MouseEvent) => {
if (!Navigation.getActiveRoute().includes(ROUTES.SETTINGS)) {
return;
Expand Down Expand Up @@ -378,7 +374,6 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
<Text style={styles.sectionTitle}>{translate(menuItemsData.sectionTranslationKey)}</Text>
{menuItemsData.items.map((item) => {
const keyTitle = item.translationKey ? translate(item.translationKey) : item.title;
const isPaymentItem = item.translationKey === 'common.wallet';
const isFocused = focusedRouteName ? focusedRouteName === item.screenName : false;

return (
Expand All @@ -393,7 +388,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
item.action();
})}
iconStyles={item.iconStyles}
badgeText={item.badgeText ?? getWalletBalance(isPaymentItem)}
badgeText={item.badgeText}
badgeStyle={item.badgeStyle}
fallbackIcon={item.fallbackIcon}
brickRoadIndicator={item.brickRoadIndicator}
Expand Down Expand Up @@ -425,18 +420,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
</View>
);
},
[
styles.pb4,
styles.mh3,
styles.sectionTitle,
styles.sectionMenuItem,
translate,
userWallet?.currentBalance,
focusedRouteName,
isExecuting,
singleExecution,
styles.productTrainingTooltipWrapper,
],
[styles.pb4, styles.mh3, styles.sectionTitle, styles.sectionMenuItem, translate, focusedRouteName, isExecuting, singleExecution, styles.productTrainingTooltipWrapper],
);

const accountMenuItems = useMemo(() => getMenuItemsSection(accountMenuItemsData), [accountMenuItemsData, getMenuItemsSection]);
Expand Down
5 changes: 3 additions & 2 deletions src/pages/settings/Wallet/WalletPage/WalletPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,14 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) {
titleStyles={styles.accountSettingsSectionTitle}
>
<>
{shouldShowLoadingSpinner ? (
{shouldShowLoadingSpinner && (
<ActivityIndicator
color={theme.spinner}
size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE}
style={[styles.mt7, styles.mb5]}
/>
) : (
)}
{!shouldShowLoadingSpinner && hasActivatedWallet && (
Copy link

@Burhan-Rashid Burhan-Rashid May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is required as in the issue they only mentioned to remove the badgeText from the wallet row not the actual wallet page. If we remove it from wallet page as well then user has to always enable the wallet to see the wallet balance that won't be a good user experience. @twilight2294 @m-natarajan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable the wallet to see the wallet balance that won't be a good user experience

The purpose here is to hide the balance if the wallet is not enabled at the first place, so this was done. c.c. @hungvu193

<OfflineWithFeedback
pendingAction={CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}
errors={walletTerms?.errors}
Expand Down
Loading