Skip to content

[Due for payment 2026-06-23] [$250] Agents-Cannot switch account from bottom drawer on visiting profile via Copilot acct #92158

Closed

Description

@applause-bot

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: v9.3.89-5
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: Exploratory around #91537
Email or phone of affected tester (no customers): applausetester+ck52826@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Iphone 16/18.7.1
App Component: User Settings

Action Performed:

Precondition: Owner has crated few agents

  1. Launch Hybrid app & log in with Expensifail account
  2. Go to Account >> Agents >> Select agent
  3. Click "Copilot into account"
  4. Tap back button on Profile page
  5. User navigate to Home tab >> Tap Account menu
  6. Tap account icon to open bottom switch account drawer
  7. Select owner account
  8. Observe account not switched to owner and still show agent's account
  9. Tap on the account icon again & observe account get switched to owner account now
  10. Repeat steps 5-9 switching accounts between agent owner & agent

Expected Result:

User able to switch accounts on selecting accounts from bottom drawer when switching between owner and agents after visiting agent's profile page via Copilot into account option

Actual Result:

Cannot switch accounts on selecting accounts from bottom drawer when switching between owner and agents after visiting agent's profile page via Copilot into account option
User ahs to click top account icon to see the switched account

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7166572_1780077554508.ScreenRecording_05-29-2026_13-37-01_1.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7166572

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. applause-bot commented on Jun 1, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/a363f0930dcbc6708ad7ed169b9b3d82243e4f0cb574326c2d5c6da696216ec4

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 1, 2026
  3. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    @NicolasBonet recently merged #91537, but they are OOO right now, so I'll auto-assign someone else.

  4. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    Triggered auto assignment to @carlosmiceli (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  5. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  6. github-actions commented on Jun 1, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  7. MelvinBot commented on Jun 1, 2026

    @MelvinBot
    Contributor

    Proposal

    ⚠️ Medium confidence. Code path is verified, but this is iOS HybridApp-only and I can't reproduce it on web, so the exact mechanism below should be confirmed on a device before merging a code fix. Two findings are solid: (1) the stale display comes from useCurrentUserPersonalDetails, and (2) PR #91537 did not introduce the bug, only a new way to trigger it.

    Problem

    After copiloting into an agent via the new Copilot into account button, switching back to the owner from the account-switcher bottom drawer leaves the switcher displaying the agent's name/avatar. The account actually switches — tapping the switcher icon a second time (forcing a re-render) reveals the correct owner account. So this is a stale render of the displayed account, not a failed switch.

    Root cause

    The name/avatar shown in the switcher come from useCurrentUserPersonalDetails(). When you tap the owner, disconnect() updates SESSION, clears Onyx, then asynchronously repopulates PERSONAL_DETAILS_LIST via openApp(). The displayed identity does not reliably re-render when that async data lands — a subsequent unrelated re-render (the second tap) is what flushes it.

    The strongest code-level suspect is the selector in CurrentUserPersonalDetailsProvider.tsx:19-28, which mutates the Onyx object in place and returns the same reference — a known pattern that can suppress useOnyx/context update notifications.

    Important: PR #91537 only added the profile button — it did not modify the AccountSwitcher, the delegate connect/disconnect logic, or CurrentUserPersonalDetailsProvider. This is a pre-existing reactivity bug that the new entry point exposes, not a defect in the PR's own code.

    Recommended changes

    Because this is a DeployBlockerCash on a new feature that isn't in production, the lowest-risk immediate unblock is to revert PR #91537 (removes the new entry point and the regression), then fix the underlying stale-render separately.

    The candidate code fix for the underlying bug is to stop mutating the selector result and return a fresh object:

    const userAccountSelector = useCallback(
        (allPersonalDetails) => ({
            ...(allPersonalDetails?.[userAccountID] ?? {}),
            accountID: userAccountID,
            email: session?.email,
        }),
        [session?.email, userAccountID],
    );

    This must be verified on iOS HybridApp before merging, since CurrentUserPersonalDetailsProvider is used app-wide and the native HybridAppModule.switchAccount session-sync timing may also contribute.

    Investigation details, alternatives considered, and open questions

    Flow traced: profile button → useSwitchToDelegator → connect()/disconnect() in Delegate.ts. disconnect() sets SESSION, then clearOnyxForDelegateTransition() wipes PERSONAL_DETAILS_LIST, then openApp() repopulates it. There's a window where the selector returns an empty-shape object, and the re-render when the owner's details arrive isn't reliably triggered.

    Alternative considered — "RHP modal not dismissed": the profile button calls switchToDelegator() without dismissing its host RHP. I ruled this out as the primary cause because the pre-existing CopilotPage, AgentsPage, and EditAgentPage all use the exact same direct-call pattern from within the RHP, so it isn't unique to this PR.

    Ruled out as irrelevant: the new openAgentsPage() useEffect (Agent.ts) is just a data read, and callFunctionIfActionIsAllowed is a pass-through for non-anonymous users.

    Open questions to confirm on device:

    • Does useOnyx use reference equality on selector output? If so, the in-place mutation at lines 21-24 definitively suppresses the update.
    • Is the staleness truly exclusive to the profile entry point, or does switching back also need a second tap after copiloting from CopilotPage? The report only exercised the profile flow.
    • Does the native HybridAppModule.switchAccount step delay PERSONAL_DETAILS_LIST repopulation on iOS?

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/92158) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  8. mountiny commented on Jun 1, 2026

    @mountiny
    Contributor

    @MelvinBot Is this feature behind beta?

  9. MelvinBot commented on Jun 1, 2026

    @MelvinBot
    Contributor

    Yes — the Custom Agents feature is gated behind the customAgent beta (CONST/index.ts:972). The Agents menu entry only appears when isBetaEnabled(CONST.BETAS.CUSTOM_AGENT) is true, and it even renders with a beta badge (InitialSettingsPage.tsx:318-328). AgentsPage.tsx:46 gates on the same beta.

    So this deploy blocker only affects users in the customAgent beta in practice.

    One caveat: the new "Copilot into account" button itself (ProfilePage.tsx:290-296) is not directly beta-checked. It's gated by isOwnedAgent = !isCurrentUser && isAgentEmail(login) && !!agentPrompt (ProfilePage.tsx:153) — the betas value read on that page is only passed to PromotedActions.message, not used to hide the button. In practice the button is still only reachable for owners who created an agent (which requires the beta), but it relies on that data precondition rather than an explicit customAgent beta check.

  10. 49 remaining items

  11. melvin-bot commented on Jun 16, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.8-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-06-23. 🎊

    For reference, here are some details about the assignees on this issue:

  12. melvin-bot commented on Jun 16, 2026

    @melvin-bot

    @aimane-chnaif The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]

  13. melvin-bot commented on Jun 19, 2026

    @melvin-bot

    @aimane-chnaif Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  14. melvin-bot commented on Jun 22, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. aimane-chnaif commented on Jun 23, 2026

    @aimane-chnaif
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: The root cause existed for long time but Add Chat and Copilot buttons to Agents page #91533 just revealed this bug.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/652654

    Regression Test Proposal

    Precondition:

    Owner has crated few agents

    Test:

    1. Go to Account >> Agents >> Select agent
    2. Click "Copilot into account"
    3. Tap back button on Profile page
    4. User navigate to Home tab >> Tap Account menu
    5. Tap account icon to open bottom switch account drawer
    6. Select owner account
    7. Verify that account is switched to owner

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-ca75-a01f-1733-2236079cedc4
  16. mallenexpensify commented on Jun 25, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @aimane-chnaif due $250 via NewDot

    ^ Test case created. Thx

    @NicolasBonet if there's an offending PR linked in the OP or a post from Melvin (or OSBotify), please assign the C+ from that since they're responsible to fix their mistakes if the bug was reported within a week of their PR hitting production. Thx.

  17. garrettmknight commented on Jul 19, 2026

    @garrettmknight
    Contributor

    $250 apprvoed for @aimane-chnaif

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.DailyKSv2EngineeringExternalAdded 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