Skip to content

[Due for payment 2026-04-17] [$250] Copilot - Account switcher shows @expensify.sms when account is phone number #86308

Closed

Description

@izarutskaya

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.42-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: EDGE cases retest
Email or phone of affected tester (no customers): undefined
Issue reported by: Applause Internal Team
Device used: Windows Windows 11 - Chrome

Action Performed:

Preconditions:

  • The user has assigned a Copilot account with a phone number via OD (Settings > Account > Profile)
  • The phone number account must have 'Display name' field empty (erase the name from OD if necessary).
  1. Go to https://staging.new.expensify.com/
  2. Sign in with the phone number of the Copilot account.
  3. Click Account > Switch accounts (top left corner, where your avatar and phone number are)

Expected Result:

When a Copilot account is registered with a phone number, the account switcher should display the phone number without @expensify.sms.

Actual Result:

When the Copilot account is a phone number, the account switcher shows @expensify.sms instead of the actual number.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Image
Bug7086587_1771901927540.explorer_YMIyLKa8RL.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022036731881981651146
  • Upwork Job ID: 2036731881981651146
  • Last Price Increase: 2026-03-25

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 25, 2026
  2. MelvinBot commented on Mar 25, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a Copilot account is registered with a phone number and has no display name set, the account switcher popover shows @expensify.sms (e.g., +15857527441@expensify.sms) instead of just the formatted phone number.

    What is the root cause of that problem?

    The root cause is in src/components/AccountSwitcher.tsx:140 in the createBaseMenuItem function:

    text: personalDetails?.displayName ?? personalDetails?.login ?? '',

    When a user hasn't set a custom display name, the backend sets displayName equal to the full login (e.g., +15857527441@expensify.sms). This raw value is used directly as the menu item title with no SMS domain stripping or phone number formatting.

    In contrast, the current user's display name in the same component (line 263) correctly uses formatPhoneNumber(displayName), and PersonalDetailsUtils.ts:75-80 has explicit handling for this case:

    // If the displayName is not set by the user, the backend sets the displayName same as the login so
    // we need to remove the sms domain from the displayName if it is an sms login.
    if (Str.isSMSLogin(login)) {
        if (displayName === login) {
            displayName = Str.removeSMSDomain(displayName);
        }

    What changes do you think we should make in order to solve the problem?

    In createBaseMenuItem at src/components/AccountSwitcher.tsx:140, wrap the text value with formatPhoneNumber() (already available in the component via useLocalize() at line 49):

    text: formatPhoneNumber(personalDetails?.displayName ?? personalDetails?.login ?? ''),
    

    formatPhoneNumber (from LocalePhoneNumber.ts) handles both stripping the @expensify.sms suffix and formatting the number for the user's locale. It also safely passes through non-phone strings unchanged, so it won't affect email-based accounts.

    Additionally, the description field on line 141 should also use formatPhoneNumber instead of just Str.removeSMSDomain to show a nicely formatted phone number rather than a raw E.164 number:

    description: formatPhoneNumber(personalDetails?.login ?? ''),
    

    What alternative solutions did you explore? (Optional)

    An alternative would be to use getDisplayNameOrDefault() from PersonalDetailsUtils.ts which already handles the displayName === login case for SMS logins. However, formatPhoneNumber() is simpler, already available in the component, and provides the additional benefit of locale-aware phone number formatting (e.g., (555) 123-4567 instead of +15551234567).


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 25, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 25, 2026
  5. melvin-bot commented on Mar 25, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 (External)

  6. melvin-bot commented on Mar 25, 2026

    @melvin-bot
  7. changed the title [-]Copilot - Account switcher shows @expensify.sms when account is phone number[/-] [+][$250] Copilot - Account switcher shows @expensify.sms when account is phone number[/+] on Mar 25, 2026
  8. ryntgh commented on Mar 25, 2026

    @ryntgh
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Copilot - Account switcher shows @expensify.sms when account is phone number

    What is the root cause of that problem?

    Popover rows built in createBaseMenuItem set the primary label from displayName or login as-is, so an SMS login still includes @expensify.sms. The secondary line already strips the domain with Str.removeSMSDomain on login, so the title and description are inconsistent and the title can show the domain.

    text: personalDetails?.displayName ?? personalDetails?.login ?? '',

    What changes do you think we should make in order to solve the problem?

    Use Str.removeSMSDomain instead of formatPhoneNumber for consistency.

    text: personalDetails?.displayName ?? personalDetails?.login ?? '',

    Note: By “consistency,” I mean making both the primary and secondary labels use the raw E.164 number, just like we did in WorkspaceMembersSelectionList

    Image

    What alternative solutions did you explore? (Optional)

    Alternatively, we can use formatPhoneNumber for the primary label to match the display name, but we shouldn’t update the description to use formatPhoneNumber as well, as Melvin suggests. We can keep using Str.removeSMSDomain for the description

  9. MobileMage commented on Mar 25, 2026

    @MobileMage
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a Copilot delegator account is registered with a phone number and has no display name set, the account switcher popover shows the raw login string (e.g. +15857527441@expensify.sms) instead of a formatted phone number.

    What is the root cause of that problem?

    In AccountSwitcher.tsx, the createBaseMenuItem helper builds the menu item for each account in the switcher popover. The text field (the primary label shown in the menu row) is set as:

    text: personalDetails?.displayName ?? personalDetails?.login ?? '',

    The ?? operator only coalesces on null or undefined — not on empty string. When the account has no display name, personalDetails.displayName is '' (empty string), so ?? does not fall through to login; the text renders as an empty string. However, when displayName is undefined, it falls through to personalDetails?.login, which is the raw login value including the @expensify.sms suffix (e.g. +15857527441@expensify.sms). Neither branch applies Str.removeSMSDomain or formatPhoneNumber, so the SMS domain leaks into the UI.

    The description field on the very next line correctly strips the domain via Str.removeSMSDomain(personalDetails?.login ?? ''), but the text field has no such treatment.

    return {
    text: personalDetails?.displayName ?? personalDetails?.login ?? '',
    description: Str.removeSMSDomain(personalDetails?.login ?? ''),
    avatarID: personalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID,

    What changes do you think we should make in order to solve the problem?

    The text field in createBaseMenuItem should fall back to the formatted phone number (via formatPhoneNumber, which already strips the SMS domain and formats the number) when displayName is absent or empty, mirroring how other parts of the app (e.g. createDisplayName in PersonalDetailsUtils.ts) handle this case. Using || instead of ?? covers the empty-string case, and wrapping the login fallback in formatPhoneNumber ensures the SMS domain is never shown.

    return {
    text: personalDetails?.displayName ?? personalDetails?.login ?? '',
    description: Str.removeSMSDomain(personalDetails?.login ?? ''),
    avatarID: personalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID,

     const createBaseMenuItem = (
         personalDetails: PersonalDetails | undefined,
         errors?: Errors,
         additionalProps: Partial<Omit<PopoverMenuItem, 'icon' | 'iconType'>> = {},
     ): PopoverMenuItem => {
         const error = Object.values(errors ?? {}).at(0) ?? '';
         return {
    -        text: personalDetails?.displayName ?? personalDetails?.login ?? '',
    +        text: personalDetails?.displayName || formatPhoneNumber(personalDetails?.login ?? ''),
             description: Str.removeSMSDomain(personalDetails?.login ?? ''),

    Switching ?? to || ensures an empty displayName string falls through to the login fallback. Wrapping the login with formatPhoneNumber strips @expensify.sms and formats the number into a human-readable string (e.g. +1 585-752-7441), consistent with how the subtitle line and the current-user display already handle phone logins.

    What alternative solutions did you explore? (Optional)

    N/A

  10. arlo-owls commented on Mar 25, 2026

    @arlo-owls

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  11. arlo-owls commented on Mar 25, 2026

    @arlo-owls

    Contributor details
    Your Expensify account email: arlo.ai.agent@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0110238ea7fec0963b

  12. melvin-bot commented on Mar 25, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  13. 25 remaining items

  14. melvin-bot commented on Apr 10, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. melvin-bot commented on Apr 17, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    • Reviewer: @eh2077 owed $250 via NewDot

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2036731881981651146/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  16. mallenexpensify commented on Apr 18, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @eh2077 due $250 via NewDot

    @eh2077 plz complete the BZ checklist and tag me in a post once you have. Thx

  17. eh2077 commented on Apr 20, 2026

    @eh2077
    Contributor

    BugZero Checklist:

    Regression Test Proposal

    Precondition:

    • NA

    Test:

    1. Sign in with a phone number that has no custom display name set
    2. Set up a Copilot delegator that is a phone number account with no display name
    3. Open the account switcher (click avatar area > Switch accounts)
    4. Verify the copilot phone number account shows a formatted phone number (e.g., +1 585-752-7441) instead of +15857527441@expensify.sms
    5. Verify email-based accounts still display correctly

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-9311-a60c-7042-ca3a56014084
  18. eh2077 commented on Apr 20, 2026

    @eh2077
    Contributor

    @mallenexpensify Checklist done, thanks!

  19. laurenreidexpensify commented on Apr 27, 2026

    @laurenreidexpensify
    Contributor

    $250 approved for @eh2077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions