You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-09-30] [Exploratory] Copilot - Greyed-out copilot retains initial access level after role change #99761
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 contributorNot a priority
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
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.
Tapping that row re-enters the Add flow, not the change-role flow. The update-role branch requires pendingFields.rolewithoutpendingFields.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.
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.
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.
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
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]
[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:
Navigate to Account > Copilot
Click Add a Copilot - Enter an email or select any users
Select the role as Full Copilot
Enter the wrong magic code
Click outside the RHP to close it
Click on the grey Copilot - Change the role to Limit - Add a copilot
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 contributorNot a priority
Activity
applause-bot commentedon Aug 28, 2026
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
MelvinBot commentedon Sep 5, 2026
Proposal
What is the root cause of that problem?
addDelegatenever writesrolewhen that copilot is already present in the local list — and after a wrong magic code, it always is.Step-by-step evidence
The failed attempt leaves a stale row. When the first
AddDelegatefails, the copilot stays inaccount.delegatedAccess.delegateswith the original role (all= Full) andpendingAction: 'add'. That's the greyed-out row —src/libs/actions/Delegate.ts:485-497.Tapping that row re-enters the Add flow, not the change-role flow. The update-role branch requires
pendingFields.rolewithoutpendingFields.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 callsaddDelegateagain, and the new role is correctly sent to the server.The bug. On that second call
existingDelegateis truthy —Delegate.ts:366— so all three Onyx writes take a{...delegate, …}branch that copies the old record and never setsrole:Delegate.ts:369-383Delegate.ts:421-435Delegate.ts:469-479The new-delegate branches immediately below each of those do set
role, which is why a clean first-time add works.What the user sees.
successDataclearspendingAction, so the row un-greys, but the badge renders the staleall—CopilotPage.tsx:248. Nothing refetches afterwards, so it sticks for the session.updateDelegateRolealready handles this correctly —Delegate.ts:747-757— so this is an omission inaddDelegate, not a design choice.Alternative explanations ruled out: the role is not lost in the route params (
SelectDelegateRolePage→ConfirmDelegatePage→ConfirmDelegateValidateCodePageall carrysubmittercorrectly), andupdateDelegateRoleis 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, setroleinside the threeexistingDelegatebranches, 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 withrole: ALL+pendingAction: 'add', calladdDelegatewithrole: SUBMITTER, and assert the role after both the optimistic and the success write.What alternative solutions did you explore? (Optional)
Rejected options
UpdateDelegateRolehas nothing to update.CopilotPage.tsx:257only clearserrorFields, and the user retries from the row itself without dismissing anything.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
melvin-bot commentedon Sep 5, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan (
External)melvin-bot commentedon Sep 5, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
melvin-bot commentedon Sep 9, 2026
@situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!
16 remaining items
[-][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[/+]melvin-bot commentedon Sep 23, 2026
@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]
melvin-bot commentedon Sep 28, 2026
@situchan Eep! 4 days overdue now. Issues have feelings too...
melvin-bot commentedon Sep 29, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Sep 29, 2026
Payment Summary
Resolving PRs:
Apply the selected copilot role when retrying an add for an existing delegate #101660
Reviewer: @situchan owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Oct 1, 2026
Payment Summary
Contributor+: @situchan due $250 via NewDot
@situchan plz complete the Contributor+ checklist and tag me in a post once you have. Thx
situchan commentedon Oct 2, 2026
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:
Do we agree 👍 or 👎
trjExpensify commentedon Nov 3, 2026
approved $250 for @situchan