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
2 changes: 1 addition & 1 deletion src/components/AccountSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
): PopoverMenuItem => {
const error = Object.values(errors ?? {}).at(0) ?? '';
return {
text: personalDetails?.displayName ?? personalDetails?.login ?? '',
text: formatPhoneNumber(personalDetails?.displayName ?? personalDetails?.login ?? ''),
description: Str.removeSMSDomain(personalDetails?.login ?? ''),
avatarID: personalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID,
icon: personalDetails?.avatar ?? '',
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/LocalePhoneNumberTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const ES_NUMBER = '+34702474537';
const US_NUMBER = '+18332403627';
const INVALID_NUMBER = '+4818332403627';
const EMAIL_LOGIN = 'user@test.com';
const US_NUMBER_WITH_SMS_DOMAIN = '+15857527441@expensify.sms';
const ES_NUMBER_WITH_SMS_DOMAIN = '+34702474537@expensify.sms';

describe('LocalePhoneNumber utils', () => {
beforeAll(() =>
Expand Down Expand Up @@ -40,5 +42,13 @@ describe('LocalePhoneNumber utils', () => {
it('should display unchanged text if the string passed to the function is not a phone number', () => {
expect(LocalePhoneNumber.formatPhoneNumber(EMAIL_LOGIN)).toBe('user@test.com');
});

it('should strip @expensify.sms domain and format a US number locally', () => {
expect(LocalePhoneNumber.formatPhoneNumber(US_NUMBER_WITH_SMS_DOMAIN)).toBe('(585) 752-7441');
});

it('should strip @expensify.sms domain and format a foreign number internationally', () => {
expect(LocalePhoneNumber.formatPhoneNumber(ES_NUMBER_WITH_SMS_DOMAIN)).toBe('+34 702 47 45 37');
});
});
});
Loading