Skip to content

[Due for payment 2026-06-16] [$250] Agent - Agent is removed as approver when saving field again. #92261

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-0
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: Use an expensifail account.
Prerequisite 2: Account has a workspace with approvals enabled.
Prerequisite 3: Account doesn´t have an agent created yet.

  1. Open the staging.new.expensify.com website.
  2. Navigate to "Workspaces" and open workspace menu.
  3. Navigate to "Workflows"
  4. On "Approvals" click on "Add Agent" > "Create Agent"
  5. Note that when RHP opens, agent is displayed as "Approver"
  6. Open the field where agent is an approver.
  7. Without making any edition, click on "Save"
  8. Note that agent is removed as approver, despite field being saved without edition.

Expected Result:

No change should be displayed on "Approver" field after being saved without any edition.

Actual Result:

Agent is removed as approver after saving "Approver" field again without making editions.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7168712_1780326625664.Agent_Approval.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7168712

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/03a5d26f1b190a343c4d98d037d406d6ac6e8ff7a780c06adc111bef152628f0

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

    Confidence: Medium-High. Root cause is verified by code tracing + elimination. I couldn't watch the Applause repro video, so the exact gesture is inferred (see "How I confirmed it" below).

    What is the root cause of that problem?

    The Approver field is a single-select list, and tapping the row that is already selected is treated as a deselect — which the page interprets as "remove the approver" and wipes it.

    When you create an agent it lands on the approver field pre-selected as approver 0. Opening that field and tapping the agent again (to "save it") hits this path:

    1. ApproverSelectionList.toggleApprover — for single-select, isAlreadySelected is true, so newSelectedApprovers = [] and it fires onSelectApprover([]).
    2. WorkspaceWorkflowsApprovalsApproverPage.toggleApprover — approvers.length === 0 ⇒ isRemovingApprover, so it calls clearApprovalWorkflowApprover and navigates back.
    3. clearApprovalWorkflowApprover sets approvers[0] = undefined, then lodashDropRightWhile collapses it to [] — the agent is gone.

    This deselect-on-re-tap logic pre-dates PR #91441 (that PR didn't touch ApproverSelectionList.tsx or the approver page). The agent flow is what exposes it: the agent arrives pre-selected, so the admin's natural "confirm/save" tap lands on the already-selected row and silently clears it. For a normal human approver you set the value by tapping (which routes you forward to the approval-limit page), so you rarely sit on a pre-selected row to re-tap.

    How I confirmed it (and why it isn't the Save button on the edit page)

    I traced the edit-page Save handler (WorkspaceWorkflowsApprovalsEditPage.updateApprovalWorkflowCallback). With no edit:

    • If the agent is still pending (CREATE_AGENT in flight) → it takes the queueDeferredAgentWorkflowSave branch and just defers; the agent is not removed.
    • If the agent is resolved → approvalWorkflow.approvers still contains the agent and approversToRemove only targets the previous approver; the agent is persisted, not removed.

    So a plain Save without touching the list cannot drop the agent. The only code path in this flow that removes it is the deselect-on-re-tap above — which matches the issue title "removed as approver when saving field again".

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

    In single-select mode, tapping the already-selected approver should be a no-op / confirm-and-go-back rather than a deselect that empties the field. Concretely, in ApproverSelectionList.toggleApprover, when !allowMultipleSelection && isAlreadySelected, don't emit an empty selection (so clearApprovalWorkflowApprover never runs for a re-tap).

    Scope it carefully so legitimate removal of a specific approver step in multi-step Control workflows still works (deselecting a slot is intended there). The safe target is the single-approver field where emptying the sole/first approver is never a valid outcome — e.g. guard the re-tap in single-select only, or guard the isRemovingApprover branch in the page so it doesn't clear the first/only approver.

    What alternative solutions did you explore? (Optional)

    A separate, related risk (not the trigger for this repro): the edit page rebuilds the workflow only from convertPolicyEmployeesToApprovalWorkflows (policy.employeeList) and never hydrates from DEFERRED_AGENT_WORKFLOW_SAVES. If an admin dismisses and re-opens the edit page while the agent is still only in deferred state, a save there could persist an agent-less workflow. Worth a follow-up, but it requires re-opening the modal, which this continuous-session repro doesn't do.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/92261) 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. 35 remaining items

  10. changed the title [-][$250] Agent - Agent is removed as approver when saving field again.[/-] [+][Due for payment 2026-06-16] [$250] Agent - Agent is removed as approver when saving field again.[/+] on Jun 9, 2026
  11. melvin-bot commented on Jun 9, 2026

    @melvin-bot

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

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

    • @abzokhattab requires payment through NewDot Manual Requests
  12. melvin-bot commented on Jun 9, 2026

    @melvin-bot

    @abzokhattab 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 12, 2026

    @melvin-bot

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

  14. melvin-bot commented on Jun 15, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. melvin-bot commented on Jun 15, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2061533304266403656/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  16. mallenexpensify commented on Jun 17, 2026

    @mallenexpensify
    Contributor

    No payment is due here cuz it was fixed via this PR which will be paid in this issue, correct @abzokhattab ?

  17. abzokhattab commented on Jun 17, 2026

    @abzokhattab
    Contributor

    @mallenexpensify correct .. we can close it

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