Skip to content

[Due for payment 2026-09-30] [Exploratory] Copilot - Greyed-out copilot retains initial access level after role change #99761

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.63-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: https://test-management.browserstack.com/projects/2219752/test-runs/71257997/folder/52723772/41236701/1704597011?sort=%2Bidentifier
Email or phone of affected tester (no customers): leungbratt6+2808@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 10/Chrome
App Component: User Settings

Action Performed:

  1. Open the NewDot app
  2. Navigate to Account /Copilot
  3. Click Add a Copilot - Enter an email or select any users
  4. Select the role as Full Copilot
  5. Enter the wrong magic code
  6. Click outside the RHp to close it
  7. Click on the grey Copilot - Change the role to Limit - Add a copilot
  8. Enter the magic code from the email

Expected Result:

App set the Copilot role to Limit

Actual Result:

App still set the Copilot role to Full

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7244959_1787904174718.copilot_role.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Nathan Lemma
Bug ID: 7244959

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. applause-bot commented on Aug 28, 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/d241d5758d42f2150794e3424880d00a8094b1613f8892e3b067eb4a90e10561

  2. added
    Bug
    on Sep 5, 2026
  3. MelvinBot commented on Sep 5, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    addDelegate never writes role when that copilot is already present in the local list — and after a wrong magic code, it always is.

    Step-by-step evidence
    1. The failed attempt leaves a stale row. When the first AddDelegate fails, the copilot stays in account.delegatedAccess.delegates with the original role (all = Full) and pendingAction: 'add'. That's the greyed-out row — src/libs/actions/Delegate.ts:485-497.

    2. Tapping that row re-enters the Add flow, not the change-role flow. The update-role branch requires pendingFields.role without pendingFields.email, but a failed add sets both, so it falls through to the "Add copilot" confirm page — src/pages/settings/Copilot/CopilotPage.tsx:237-242. This matches step 7 in the report ("Add a copilot" button). So the second submit calls addDelegate again, and the new role is correctly sent to the server.

    3. The bug. On that second call existingDelegate is truthy — Delegate.ts:366 — so all three Onyx writes take a {...delegate, …} branch that copies the old record and never sets role:

      The new-delegate branches immediately below each of those do set role, which is why a clean first-time add works.

    4. What the user sees. successData clears pendingAction, so the row un-greys, but the badge renders the stale all — CopilotPage.tsx:248. Nothing refetches afterwards, so it sticks for the session.

    updateDelegateRole already handles this correctly — Delegate.ts:747-757 — so this is an omission in addDelegate, not a design choice.

    Alternative explanations ruled out: the role is not lost in the route params (SelectDelegateRolePage → ConfirmDelegatePage → ConfirmDelegateValidateCodePage all carry submitter correctly), and updateDelegateRole is never called in this flow.

    Because the correct role does reach the server, this is very likely display-only — reloading the app should show Limited. I have not verified the server side, so that's worth confirming during QA.

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

    In addDelegate, set role inside the three existingDelegate branches, exactly as the adjacent new-delegate branches do, so a retry's role overwrites the leftover failed entry. Include the failure branch too, so a second wrong code leaves the row showing the role the user just attempted.

    Add a regression test in tests/actions/DelegateTest.ts: seed one delegate with role: ALL + pendingAction: 'add', call addDelegate with role: SUBMITTER, and assert the role after both the optimistic and the success write.

    What alternative solutions did you explore? (Optional)

    Rejected options
    • Route the greyed row into the update-role flow instead. Wrong: the copilot doesn't exist server-side yet, so UpdateDelegateRole has nothing to update.
    • Clear the failed entry when the user dismisses the error. Doesn't help — CopilotPage.tsx:257 only clears errorFields, and the user retries from the row itself without dismissing anything.
    • Refetch the copilot list after a successful add. Papers over the stale write and adds a round trip.

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


    view run · no recording available

  4. added
    External
    on Sep 5, 2026
  5. melvin-bot commented on Sep 5, 2026

    @melvin-bot

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

  6. melvin-bot commented on Sep 5, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. melvin-bot commented on Sep 9, 2026

    @melvin-bot

    @situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!

  8. 16 remaining items

  9. added
    Daily
    and removed
    Weekly
    on Sep 23, 2026
  10. changed the title [-][Exploratory] Copilot - Greyed-out copilot retains initial access level after role change[/-] [+][Due for payment 2026-09-30] [Exploratory] Copilot - Greyed-out copilot retains initial access level after role change[/+] on Sep 23, 2026
  11. melvin-bot commented on Sep 23, 2026

    @melvin-bot

    @situchan

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.91-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-09-30. 🎊

    The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ 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]

  12. melvin-bot commented on Sep 28, 2026

    @melvin-bot

    @situchan Eep! 4 days overdue now. Issues have feelings too...

  13. added
    Awaiting Payment
    on Sep 29, 2026
  14. melvin-bot commented on Sep 29, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. melvin-bot commented on Sep 29, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  16. mallenexpensify commented on Oct 1, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @situchan due $250 via NewDot

    @situchan plz complete the Contributor+ checklist and tag me in a post once you have. Thx

  17. situchan commented on Oct 2, 2026

    @situchan
    Contributor

    Contributor+ Checklist:

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

      Link to the comment on the PR:
      Link to the comment on the Issue:

    • [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.

    Regression Test Proposal

    Precondition:

    Test:

    1. Navigate to Account > Copilot
    2. Click Add a Copilot - Enter an email or select any users
    3. Select the role as Full Copilot
    4. Enter the wrong magic code
    5. Click outside the RHP to close it
    6. Click on the grey Copilot - Change the role to Limit - Add a copilot
    7. Enter the magic code from the email
    8. Verify that Copilot role is set to Limit

    Do we agree 👍 or 👎

  18. trjExpensify commented on Nov 3, 2026

    @trjExpensify
    Contributor

    approved $250 for @situchan

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternalNot a priority

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions