Skip to content
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
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8260,6 +8260,7 @@ const CONST = {
HAS_LOGIN_LIST_ERROR: 'hasLoginListError',
HAS_WALLET_TERMS_ERRORS: 'hasWalletTermsErrors',
HAS_LOGIN_LIST_INFO: 'hasLoginListInfo',
HAS_HOME_ADDRESS_INFO: 'hasHomeAddressInfo',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BTW if we desire to display DebugTabView for this new info we need to add the corresponding copy and routes likeHAS_LOGIN_LIST_INFO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think we need it for now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will handle it once #99788 is merged since that PR changes the Route handler.

HAS_SUBSCRIPTION_INFO: 'hasSubscriptionInfo',
HAS_PHONE_NUMBER_ERROR: 'hasPhoneNumberError',
HAS_PENDING_CARD_INFO: 'hasPendingCardInfo',
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useAccountIndicatorChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {hasPendingExpensifyCardAction} from '@libs/CardUtils';
import {hasSubscriptionGreenDotInfo, hasSubscriptionRedDotError} from '@libs/SubscriptionUtils';
import {expensifyLoginsSelector, hasDeviceManagementError, hasLoginListError, hasLoginListInfo} from '@libs/UserUtils';

import useTimeSensitiveHomeAddress from '@pages/home/TimeSensitiveSection/hooks/useTimeSensitiveHomeAddress';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type IndicatorStatus from '@src/types/utils/IndicatorStatus';
Expand Down Expand Up @@ -42,6 +44,7 @@ function useAccountIndicatorChecks(): AccountIndicatorChecksResult {
companyCards: {shouldShowRBR: hasCompanyCardFeedErrors},
} = useCardFeedErrors();
const {isPolicyAdmin} = usePoliciesWithCardFeedErrors();
const {shouldShowAddHomeAddress} = useTimeSensitiveHomeAddress();

const accountChecks: Partial<Record<IndicatorStatus, boolean>> = {
[CONST.INDICATOR_STATUS.HAS_USER_WALLET_ERRORS]: Object.keys(userWallet?.errors ?? {}).length > 0,
Expand Down Expand Up @@ -69,6 +72,7 @@ function useAccountIndicatorChecks(): AccountIndicatorChecksResult {

const infoChecks: Partial<Record<IndicatorStatus, boolean>> = {
[CONST.INDICATOR_STATUS.HAS_LOGIN_LIST_INFO]: !!loginList && hasLoginListInfo(loginList, session?.email),
[CONST.INDICATOR_STATUS.HAS_HOME_ADDRESS_INFO]: shouldShowAddHomeAddress,
Comment thread
fedirjh marked this conversation as resolved.
Resolved
[CONST.INDICATOR_STATUS.HAS_PENDING_CARD_INFO]: hasPendingExpensifyCardAction(allCards, privatePersonalDetails),
[CONST.INDICATOR_STATUS.HAS_SUBSCRIPTION_INFO]: hasSubscriptionGreenDotInfo(
stripeCustomerId,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/UserUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,13 @@ function getProfilePageBrickRoadIndicator(
privatePersonalDetails: OnyxEntry<PrivatePersonalDetails>,
vacationDelegate: OnyxEntry<VacationDelegate>,
email: string | undefined,
shouldShowAddHomeAddress = false,
): LoginListIndicator {
const hasPhoneNumberError = !!privatePersonalDetails?.errorFields?.phoneNumber;
if (hasLoginListError(loginList) || hasPhoneNumberError || !isEmptyObject(vacationDelegate?.errors)) {
return CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
}
if (hasLoginListInfo(loginList, email)) {
if (hasLoginListInfo(loginList, email) || shouldShowAddHomeAddress) {
return CONST.BRICK_ROAD_INDICATOR_STATUS.INFO;
}

Expand Down
4 changes: 3 additions & 1 deletion src/pages/settings/useInitialSettingsPageMenuData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {getFreeTrialText, hasSubscriptionRedDotError} from '@libs/SubscriptionUt
import {shouldHideOldAppRedirect} from '@libs/TryNewDotUtils';
import {expensifyLoginsSelector, getProfilePageBrickRoadIndicator, hasDeviceManagementError} from '@libs/UserUtils';

import useTimeSensitiveHomeAddress from '@pages/home/TimeSensitiveSection/hooks/useTimeSensitiveHomeAddress';
import {BACKGROUND_LOCATION_TRACKING_TASK_NAME} from '@pages/iou/request/step/IOURequestStepDistanceGPS/const';
import {stopGpsTripNotification} from '@pages/iou/request/step/IOURequestStepDistanceGPS/GPSNotifications';

Expand Down Expand Up @@ -85,6 +86,7 @@ function useInitialSettingsPageMenuData(currentUserPersonalDetails: CurrentUserP
const {translate} = useLocalize();
const hasActivatedWallet = ([CONST.WALLET.TIER_NAME.GOLD, CONST.WALLET.TIER_NAME.PLATINUM] as string[]).includes(userWallet?.tierName ?? '');
const hasLockedBankAccount = bankAccountList ? Object.values(bankAccountList).some((bankAccount) => bankAccount.accountData?.state === CONST.BANK_ACCOUNT.STATE.LOCKED) : false;
const {shouldShowAddHomeAddress} = useTimeSensitiveHomeAddress();
const [firstDayFreeTrial] = useOnyx(ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL);
const [isTrackingGPS = false] = useOnyx(ONYXKEYS.GPS_DRAFT_DETAILS, {
selector: isTrackingSelector,
Expand Down Expand Up @@ -233,7 +235,7 @@ function useInitialSettingsPageMenuData(currentUserPersonalDetails: CurrentUserP
surveyCompletedWithinLastMonth = daysSinceLastSurvey < surveyThresholdInDays;
}

const profileBrickRoadIndicator = getProfilePageBrickRoadIndicator(loginList, privatePersonalDetails, vacationDelegate, session?.email);
const profileBrickRoadIndicator = getProfilePageBrickRoadIndicator(loginList, privatePersonalDetails, vacationDelegate, session?.email, shouldShowAddHomeAddress);
const securityBrickRoadIndicator = hasDeviceManagementErrorValue ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined;
const accountItems = navigationAccountMenuItemsData.items.map((item): MenuData => {
if (item.screenName === SCREENS.SETTINGS.PROFILE.ROOT) {
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/InitialSettingsPageTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,26 @@ describe('InitialSettingsPage - agent account', () => {
});
});

it('shows info GBR on Profile when commuter exclusions require a missing home address', async () => {
await setupUser('user@expensify.com');

await act(async () => {
await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}1`, {
id: '1',
name: 'Boulder Development',
commuterExclusions: {method: 'homeAndOffice'},
});
});
await waitForBatchedUpdatesWithAct();

renderPage();
await waitForBatchedUpdatesWithAct();

await waitFor(() => {
expect(screen.getByTestId('decoration-Profile-rbr').children).toEqual([CONST.BRICK_ROAD_INDICATOR_STATUS.INFO]);
});
});

it('shows Subscription for agent account', async () => {
mockUseSubscriptionPlan.mockReturnValue(CONST.POLICY.TYPE.TEAM);
await setupUser('testbot_123@expensify.ai', true);
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/useAccountTabIndicatorStatusTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ const TEST_CASES = {
indicatorColor: defaultTheme.success,
status: CONST.INDICATOR_STATUS.HAS_LOGIN_LIST_INFO,
},
hasHomeAddressInfo: {
name: 'has missing home address info',
indicatorColor: defaultTheme.success,
status: CONST.INDICATOR_STATUS.HAS_HOME_ADDRESS_INFO,
},
hasEmployeeCardFeedErrors: accountCardFeedTestCases.employee,
hasPolicyAdminCardFeedErrors: accountCardFeedTestCases.admin,
hasLockedBankAccount: {
Expand Down Expand Up @@ -156,6 +161,14 @@ const getMockForTestCase = ({name, status}: IndicatorTestCase) =>
: undefined,
},
[ONYXKEYS.PRIVATE_PERSONAL_DETAILS]: {
addresses:
status === CONST.INDICATOR_STATUS.HAS_HOME_ADDRESS_INFO
? []
: [
{
street: '123 Test St',
},
],
errorFields:
status === CONST.INDICATOR_STATUS.HAS_PHONE_NUMBER_ERROR
? {
Expand All @@ -172,6 +185,7 @@ const getMockForTestCase = ({name, status}: IndicatorTestCase) =>
owner: name === accountCardFeedTestCases.admin.name ? 'johndoe12@expensify.com' : 'otheruser@expensify.com',
role: name === accountCardFeedTestCases.admin.name ? 'admin' : 'user',
policyAccountID: cardFeed.policyAccountID,
commuterExclusions: status === CONST.INDICATOR_STATUS.HAS_HOME_ADDRESS_INFO ? {method: CONST.POLICY.COMMUTER_EXCLUSION_METHOD.HOME_AND_OFFICE} : undefined,
},
[ONYXKEYS.CARD_LIST]: {
card123: {
Expand Down
Loading