From bca029dc2b39d11f3e1a6a0fe676ff75c98607a0 Mon Sep 17 00:00:00 2001 From: "Eric Han (via MelvinBot)" Date: Tue, 31 Mar 2026 14:51:56 +0000 Subject: [PATCH 1/4] Strip SMS domain and format phone numbers in account switcher menu items Wrap the text and description fields in createBaseMenuItem with formatPhoneNumber so that copilot accounts registered with phone numbers show a formatted number instead of the raw login with @expensify.sms. Co-authored-by: Eric Han --- src/components/AccountSwitcher.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/AccountSwitcher.tsx b/src/components/AccountSwitcher.tsx index 6f2cc49373f0..13eb0a0c9989 100644 --- a/src/components/AccountSwitcher.tsx +++ b/src/components/AccountSwitcher.tsx @@ -137,8 +137,8 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) { ): PopoverMenuItem => { const error = Object.values(errors ?? {}).at(0) ?? ''; return { - text: personalDetails?.displayName ?? personalDetails?.login ?? '', - description: Str.removeSMSDomain(personalDetails?.login ?? ''), + text: formatPhoneNumber(personalDetails?.displayName ?? personalDetails?.login ?? ''), + description: formatPhoneNumber(personalDetails?.login ?? ''), avatarID: personalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, icon: personalDetails?.avatar ?? '', iconType: CONST.ICON_TYPE_AVATAR, From a52cdb9f0b74302afe2a49e08a0c16df3c37c1ec Mon Sep 17 00:00:00 2001 From: "Eric Han (via MelvinBot)" Date: Thu, 2 Apr 2026 14:59:34 +0000 Subject: [PATCH 2/4] Add unit tests for formatPhoneNumber with SMS domain inputs Adds two test cases to LocalePhoneNumberTest covering the @expensify.sms domain scenario used by the AccountSwitcher: a US number formatted locally and a foreign number formatted internationally. Co-authored-by: Eric Han --- tests/unit/LocalePhoneNumberTest.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit/LocalePhoneNumberTest.ts b/tests/unit/LocalePhoneNumberTest.ts index 99f53e7f980a..ee16ab317864 100644 --- a/tests/unit/LocalePhoneNumberTest.ts +++ b/tests/unit/LocalePhoneNumberTest.ts @@ -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(() => @@ -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'); + }); }); }); From f5b806e5fc37f2bedbc9f1935b61e3773f33ecac Mon Sep 17 00:00:00 2001 From: "Eric Han (via MelvinBot)" Date: Tue, 7 Apr 2026 13:07:27 +0000 Subject: [PATCH 3/4] Revert text line to not use formatPhoneNumber Display names should not be formatted as phone numbers. Co-authored-by: Eric Han --- src/components/AccountSwitcher.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AccountSwitcher.tsx b/src/components/AccountSwitcher.tsx index 13eb0a0c9989..89582086605f 100644 --- a/src/components/AccountSwitcher.tsx +++ b/src/components/AccountSwitcher.tsx @@ -137,7 +137,7 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) { ): PopoverMenuItem => { const error = Object.values(errors ?? {}).at(0) ?? ''; return { - text: formatPhoneNumber(personalDetails?.displayName ?? personalDetails?.login ?? ''), + text: personalDetails?.displayName ?? personalDetails?.login ?? '', description: formatPhoneNumber(personalDetails?.login ?? ''), avatarID: personalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, icon: personalDetails?.avatar ?? '', From 36db0c43dc9bd86fee6e419eabc7ad8f0edebd35 Mon Sep 17 00:00:00 2001 From: "Eric Han (via MelvinBot)" Date: Tue, 7 Apr 2026 13:13:08 +0000 Subject: [PATCH 4/4] Apply formatPhoneNumber to text prop only, keep Str.removeSMSDomain for description Co-authored-by: Eric Han --- src/components/AccountSwitcher.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/AccountSwitcher.tsx b/src/components/AccountSwitcher.tsx index 89582086605f..0247f8cd19c1 100644 --- a/src/components/AccountSwitcher.tsx +++ b/src/components/AccountSwitcher.tsx @@ -137,8 +137,8 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) { ): PopoverMenuItem => { const error = Object.values(errors ?? {}).at(0) ?? ''; return { - text: personalDetails?.displayName ?? personalDetails?.login ?? '', - description: formatPhoneNumber(personalDetails?.login ?? ''), + text: formatPhoneNumber(personalDetails?.displayName ?? personalDetails?.login ?? ''), + description: Str.removeSMSDomain(personalDetails?.login ?? ''), avatarID: personalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, icon: personalDetails?.avatar ?? '', iconType: CONST.ICON_TYPE_AVATAR,