Skip to content

[Due for payment 2026-03-18][$250] Copilot - Limited copilot can retract expense, main account avatar appears briefly #83544

Closed

Description

@jponikarchuk

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.26-4
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/folder/13176687/test-cases/41236700
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: MacBook Air 15.7.4 Chrome
App Component: Money Requests

Action Performed:

Preconditions: User A added User B as a copilot with limited access

  1. As User A, create a workspace with submission frequency set to manual, enabled approvals and payments
  2. As User A, add an expense in the workspace chat
  3. Sign in as User B, switch to the User A's account
  4. As User B, open expense details from step 2, click Submit
  5. As User B, open More menu, click Retract
  6. Observe the system message

Expected Result:

Limited copilot is not able to retract expense. When the copilot account retracts the expense, main account's avatar does not appear briefly above the "retracted" system message

Actual Result:

Limited copilot as able to retract the expense.
When the full or limited copilot submits the expense, then retracts it, the system message appears with the main account avatar briefly

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @brianlee-expensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022026945522407032258
  • Upwork Job ID: 2026945522407032258
  • Last Price Increase: 2026-03-05

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 26, 2026
  2. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 26, 2026
  3. melvin-bot commented on Feb 26, 2026

    @melvin-bot

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

  4. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    Triggered auto assignment to @brianlee-expensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. changed the title [-]Copilot - Limited copilot can retract expense, main account avatar appears briefly[/-] [+][$250] Copilot - Limited copilot can retract expense, main account avatar appears briefly[/+] on Feb 26, 2026
  6. melvin-bot commented on Feb 26, 2026

    @melvin-bot
  7. nkdengineer commented on Feb 26, 2026

    @nkdengineer
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-02-26 09:12:02 UTC.

    Proposal

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

    Limited copilot as able to retract the expense.
    When the full or limited copilot submits the expense, then retracts it, the system message appears with the main account avatar briefly

    What is the root cause of that problem?

    1. We don't show the limit access model for retract action like reject

    retractReport(moneyRequestReport, chatReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep);

    1. When the copilot retract expense, we don't add delegateAccountID to optimistic retract action then the main avatar is displayed briefly

    function buildOptimisticRetractedReportAction(created = DateUtils.getDBTime()): OptimisticRetractedReportAction {

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

    1. Show limit access model like we did for reject action
    if (isDelegateAccessRestricted) {
                        showDelegateNoAccessModal();
                        return;
                    }
    retractReport(moneyRequestReport, chatReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep); 
    

    retractReport(moneyRequestReport, chatReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep);

    1. Add delegateAccountID to the optimistic retract action
    const delegateAccountDetails = getPersonalDetailByEmail(delegateEmail);
    
    delegateAccountID: delegateAccountDetails?.accountID
    

    function buildOptimisticRetractedReportAction(created = DateUtils.getDBTime()): OptimisticRetractedReportAction {

    We also need to check for other secondary actions if it has the same problem

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  8. MobileMage commented on Feb 26, 2026

    @MobileMage
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  9. github-actions commented on Feb 26, 2026

    @github-actions
    Contributor

    ⚠️ @MobileMage Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  10. MelvinBot commented on Feb 26, 2026

    @MelvinBot
    Contributor

    Proposal

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

    There are two bugs when a copilot interacts with expenses:

    1. Permission bug: A limited copilot (delegate with "submitter" role) can retract an expense, when they should not be allowed to.
    2. Avatar bug: When any copilot (full or limited) retracts an expense, the main account's avatar briefly flashes above the "retracted" system message before being corrected by the server response.

    What is the root cause of that problem?

    Bug 1 (Permission): The RETRACT action handler in MoneyReportHeader.tsx is missing the isDelegateAccessRestricted check. Every other write action in the same file (PAY, APPROVE, UNAPPROVE, HOLD, REMOVE_HOLD, REJECT) checks isDelegateAccessRestricted and shows the delegate-no-access modal before proceeding. The RETRACT handler at line 1576 directly calls retractReport() with no guard.

    For comparison, the HOLD handler at line 1365 follows the correct pattern:

    if (isDelegateAccessRestricted) {
        showDelegateNoAccessModal();
        return;
    }
    

    Bug 2 (Avatar): The buildOptimisticRetractedReportAction function in ReportUtils.ts:8061-8085 does not set delegateAccountID on the optimistic report action. Without this field, the avatar rendering code in useReportActionAvatars.ts cannot detect a delegate is acting, so it falls through to actorAccountID (the main account). When the server response arrives with the correct delegateAccountID, the avatar corrects itself — producing the brief flash.

    Other optimistic action builders like buildOptimisticSubmittedReportAction at line 7389 correctly include delegateAccountID: delegateAccountDetails?.accountID.

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

    Fix 1 — Add delegate restriction check to RETRACT handler:

    In src/components/MoneyReportHeader.tsx, add the isDelegateAccessRestricted guard to the RETRACT onSelected handler (around line 1576), matching the pattern used by HOLD, REJECT, UNAPPROVE, etc.:

    onSelected: () => {
        if (isDelegateAccessRestricted) {
            showDelegateNoAccessModal();
            return;
        }
        retractReport(...);
    },
    

    Fix 2 — Add delegateAccountID to optimistic retracted action:

    In src/libs/ReportUtils.ts:

    1. Add 'delegateAccountID' to the OptimisticRetractedReportAction Pick type (line 543-546).
    2. In buildOptimisticRetractedReportAction (line 8061), resolve the delegate details and include delegateAccountID:
    const delegateAccountDetails = getPersonalDetailByEmail(delegateEmail);
    // Then in the return object:
    delegateAccountID: delegateAccountDetails?.accountID,
    

    What alternative solutions did you explore? (Optional)

    The REOPEN action handler at line 1585 has the same missing isDelegateAccessRestricted check. Additionally, buildOptimisticReopenedReportAction (line 8088) and buildOptimisticRejectReportAction (line 12632) have the same missing delegateAccountID pattern. These may warrant fixes in the same PR to prevent similar copilot issues.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  11. 16 remaining items

  12. nkdengineer commented on Mar 9, 2026

    @nkdengineer
    Contributor

    @brunovjk The PR is ready for review.

  13. brunovjk commented on Mar 17, 2026

    @brunovjk
    Contributor

    PR went into production on March 11th according to this deploy checklist.

  14. changed the title [-][$250] Copilot - Limited copilot can retract expense, main account avatar appears briefly[/-] [+][Due for payment 2026-03-18][$250] Copilot - Limited copilot can retract expense, main account avatar appears briefly[/+] on Mar 17, 2026
  15. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    ReviewingHas a PR in review
    on Mar 17, 2026
  16. melvin-bot commented on Mar 17, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  17. brianlee-expensify commented on Mar 18, 2026

    @brianlee-expensify
    Contributor

    Payment Summary

  18. twisterdotcom commented on Mar 19, 2026

    @twisterdotcom
    Contributor

    @brunovjk has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-f72b-a8ab-c323-c11e717d27b4
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