Skip to content

[Due for payment 2026-06-18] Agent - Agent deleted offline is still displayed as "Approver" and still selectable. #92262

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: 9.3.90-1
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: #91441
Email or phone of affected tester (no customers): applausetester+ib0005@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Workspace Settings

Action Performed:

Prerequisite: User an expensifail account.
Prerequisite 2: Account has a workspace with "Approvals" enabled.

  1. Open the staging.new.expensify.com wesbite.
  2. Navigate to "Account" > "Agents"
  3. Create a new agent.
  4. Navigate to "Workspaces" > "Workflows"
  5. Click on "Add Agent" > "Save"
  6. Note that agent was added as approver.
  7. Turn off internet connection.
  8. Return to "Account" > Agents" and delete the agent.
  9. Return to "Workspaces" > "Workflows"
  10. Note that agent is still displayed as approver.
  11. Tap on approver to open "Edit Approval" RHP.
  12. Click on "Approver" field where agent is an approver two times to reach "Set Approver".
  13. Click on agent to remove it as approver.
  14. Reopen approver field.
  15. Click on agent again.
  16. Note that agent is added as approver again, despite being deleted.

Expected Result:

Deleted agent should automatically disappear as "Approver"

Actual Result:

Agent that was deleted while offline is still displayed as approver and is still selectable.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7168784_1780330372035.Agent_Approval_2.mp4

View all open jobs on GitHub

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

Issue OwnerCurrent Issue Owner: @mkhutornyi

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 1, 2026
  2. 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/26c4244c876e5691a60ff123e59691806053694692bdebe53b72b6452f5c5fa0

  3. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #91441

  4. melvin-bot commented on Jun 1, 2026

    @melvin-bot

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

  5. 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.
  6. MelvinBot commented on Jun 1, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    deleteAgent only writes the deletion state optimistically to the agent's prompt key (sharedNVP_agentPrompt_<accountID> → pendingAction: DELETE). It does not optimistically touch personalDetailsList or the policy employeeList — those removals live in successData, which never runs while offline.

    But the Workflows UI reads the agent from employeeList + personalDetails, not from the prompt key. So while offline the agent is still a full member/approver, which produces both symptoms:

    • Still shown as approver: the workflow card derives approvers by walking the submitsTo / forwardsTo chain in employeeList via calculateApprovers. The agent's employeeList entry is untouched, so it stays in the chain.
    • Still selectable: the Set Approver list is built from employeeList and only drops entries whose employeeList entry has pendingAction === DELETE. deleteAgent sets that flag on the prompt key instead, so the filter never matches.

    This is why it only "fixes itself" once you reconnect — the real removal arrives from the server's DELETE_AGENT response, not from optimistic data.

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

    Give deleteAgent an optimistic update that mirrors what regular workspace member removal already does, instead of only flagging the prompt key.

    1. Resolve the agent's email from personalDetailsList[accountID].login, then for every policy whose employeeList contains that email, optimistically merge {[agentEmail]: {pendingAction: DELETE}} into employeeList (and reverse it in failureData). This alone fixes the still-selectable symptom and removes the agent from the card's member list (both DELETE filters then match). See the existing template in removeMembers.
    2. To also drop the agent from the displayed approver chain, rewire the affected workflows the same way member removal does — recompute via updateWorkflowDataOnApproverRemoval and write the resulting submitsTo/forwardsTo changes into the optimistic employeeList, so anyone forwarding to the agent falls back to the owner/default approver. Marking the agent pendingAction: DELETE is not enough on its own here, because calculateApprovers walks the chain without skipping pending‑delete entries.
    Why marking pending-delete alone won't remove the approver row

    calculateApprovers (WorkflowUtils.ts:58-93) follows submitsTo→forwardsTo and pushes any email that still exists in employeeList, regardless of pendingAction. The pendingAction === DELETE filters in convertPolicyEmployeesToApprovalWorkflows (L182-L184) only affect availableMembers and the workflow members list — not the approver chain itself. So the chain must be rewired, not just flagged.

    Scope note

    deleteAgent(accountID) is invoked globally from Settings > Agents and isn't policy-scoped, while an agent can be an approver in multiple workspaces. The optimistic update therefore needs to scan all loaded policies for the agent's email — the same set the server's DELETE_AGENT updates server-side.

    Root cause confidence: High. The exact fix shape is Medium confidence given the multi-policy chain-rewiring involved.

    What alternative solutions did you explore? (Optional)

    If full offline chain-rewiring is deemed too large for a deploy-blocker turnaround, a narrower stopgap is to disable/greyout the delete action (or the agent's approver row) while offline so the UI never shows a stale-but-selectable agent. This trades offline-first behavior for correctness and should be confirmed with the feature owner.


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

  7. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Jun 1, 2026
  8. lakchote commented on Jun 1, 2026

    @lakchote
    Contributor

    Behind beta, demoting.

  9. 21 remaining items

  10. melvin-bot commented on Jun 12, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  11. mkhutornyi commented on Jun 15, 2026

    @mkhutornyi
    Contributor

    The linked blocker is not a regression as per #93260 (comment).

  12. melvin-bot commented on Jun 15, 2026

    @melvin-bot

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

  13. melvin-bot commented on Jun 17, 2026

    @melvin-bot

    Skipping the payment summary for this issue since all the assignees are employees or vendors. If this is incorrect, please manually add the payment summary SO.

  14. melvin-bot commented on Jun 17, 2026

    @melvin-bot

    @mallenexpensify Huh... This is 4 days overdue. Who can take care of this?

  15. mallenexpensify commented on Jun 19, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @mkhutornyi due $250 via NewDot

    Checking on updating test cases when feature is removed, will reopen, if needed.

  16. trjExpensify commented on Jun 23, 2026

    @trjExpensify
    Contributor

    approved $250 for @mkhutornyi

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions