App icon indicating copy to clipboard operation
App copied to clipboard

[$175] There right approver is not shown after turning back the approval mode

Open applause-bot[bot] opened this issue 3 weeks ago • 21 comments

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


Version Number: 9.5.35-1 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://github.com/Expensify/App/pull/105595 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: iPhone 11 App Component: Workspace Settings

Action Performed:

Precondition: Have a workspace > invite a user A and make user A the approver

  1. Submit an expense to a workspace chat
  2. Open the report, notice that the next step show user A as the approver
  3. Go to workspace > Turn off the approval mode > Turn it back on
  4. Set user A as the approver
  5. Go to workspace chat > Open report

Expected Result:

the next step show user A as the approver

Actual Result:

The next step show the owner(you) as the approver

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [ ] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/b11735d2-41a7-45d9-9d19-3879ccd75c35

View all open jobs on GitHub

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

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @AndrewGable

applause-bot[bot] avatar Nov 10 '26 07:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/ab15f56c35f372e8273c73c20158b50bf0b7d684a35fcfaf72712ad1a0ed93a3

applause-bot[bot] avatar Nov 10 '26 07:11 applause-bot[bot]

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

melvin-bot[bot] avatar Nov 10 '26 08:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022120064872446889807

melvin-bot[bot] avatar Nov 10 '26 08:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

Live state analysis on Web reveals that this is not merely a presentation/stale banner defect: the report is genuinely assigned to the workspace owner on the server.

  1. Backend Reassignment on Approval Disable:
    • In src/libs/actions/Policy/Policy.ts:1191–1210, toggling approvals off sets approvalMode: OPTIONAL. On the backend, disabling approvals strips approval routing and moves all existing submitted reports under the workspace owner (report.managerID: ownerAccountID).
  2. Missing Re-routing on Default Approver Update:
    • When approvals are re-enabled, the default approver resets to the owner.
    • When the user subsequently edits the default workflow (Everyone) and sets Member A as the approver, updateApprovalWorkflowRules calls updatePolicyDefaultApprover (src/libs/actions/Workflow.ts:387–405), sending WRITE_COMMANDS.UPDATE_WORKSPACE_APPROVAL.
    • UPDATE_WORKSPACE_APPROVAL updates policy.approver = A, but the backend does not automatically re-assign existing submitted reports from the owner to A.
    • Consequently:
      • policy.approver: Member A
      • report.managerID: Workspace Owner
      • report.nextStep.actorAccountID: Workspace Owner
    • Because report.managerID genuinely belongs to the owner, the Next Step banner correctly identifies the owner.

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

There are two distinct paths depending on Expensify Product consensus:

Path 1: If existing submitted reports should follow the newly updated default approver (Recommended if reassignment is desired):

This requires client-side optimistic synchronization paired with backend UpdateWorkspaceApproval support:

  1. In src/libs/actions/Workflow.ts (updatePolicyDefaultApprover / updateApprovalWorkflowRules):
    • When the default approver changes from owner to Member A (newDefaultApproverAccountID !== previousDefaultApproverAccountID):
    • Find all submitted expense reports on the workspace:
      const submittedReports = Object.values(allReports ?? {}).filter(
          (report) => report?.policyID === policy.id && ReportUtils.isExpenseReport(report) && report.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED,
      );
      
    • Optimistically update managerID and recompute nextStep for those reports:
      const reportUpdates: Record<string, Partial<Report>> = {};
      for (const submittedReport of submittedReports) {
          reportUpdates[`${ONYXKEYS.COLLECTION.REPORT}${submittedReport.reportID}`] = {
              managerID: newDefaultApproverAccountID,
              nextStep: buildOptimisticNextStep({
                  report: {...submittedReport, managerID: newDefaultApproverAccountID},
                  policy: updatedPolicy,
                  rules: updatedRules,
                  predictedNextStatus: CONST.REPORT.STATUS_NUM.SUBMITTED,
              }),
              pendingFields: {managerID: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE},
          };
      }
      
    • Include reportUpdates in optimisticData, successData, and failureData in updatePolicyDefaultApprover.
  2. Backend Alignment: Ensure backend UpdateWorkspaceApproval (or setWorkspaceApprovalMode) moves submitted reports back to the new default approver upon configuration update.

Path 2: If the owner retaining existing submitted reports after an off/on cycle is expected product behavior (Working As Designed):

  • If Product confirms that submitted reports should remain locked to the owner who held them during the toggle, and only newly submitted reports should route to Member A, then the current client behavior is 100% correct and expected (Not a Bug). The banner accurately informs the user that the owner holds the approval authority for that specific report.

What alternative solutions did you explore? (Optional)

  • Patching only NextStepUtils.ts to display Member A based on policy.approver without updating managerID: Strongly rejected because report.managerID determines who can actually click the "Approve" button. If the banner claimed Member A was the approver while managerID was the owner, Member A would not be able to approve the report, introducing a fatal permission deadlock.

Tests

  1. In a workspace with approvals on, set Member A as default approver.
  2. Submit an expense report -> verify Next Step shows "Waiting for A to approve".
  3. Go to Workflows > Approvals, turn approvals off, then turn back on.
  4. Set Member A as approver again and save.
  5. Re-open the submitted report.
  6. Verify behavior matches the decided product spec (either optimistically routes to A, or consistently indicates the owner).

  • Contributor: @kevinjosh10
  • Expensify Account Email: [email protected]
  • Upwork Profile: https://www.upwork.com/freelancers/~0131dae36abcf59374

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 10 '26 08:11 kevinjosh10

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 10 '26 08:11 melvin-bot[bot]

🤖 Web test steps verification results: ⚠️ partial

The required second-member precondition could not be established on dev NewDot web. VERIFY 1–5 were not executed; no product failure for this issue was observed.

Workspace Members screen after invitation attempt
Step Status
Workspace contains another member A as approverAfter the invitation attempt, Members still showed only the owner.
Workspace Members screen after invitation attempt
❌
Submit an expense to workspace chatNot executed: member precondition blocked.
⚠️
Confirm the original next step names ANot executed: member precondition blocked.
⚠️
Turn approvals off, then onNot executed: member precondition blocked.
⚠️
Select A as approver againNot executed: member A was unavailable.
⚠️
Reopen the report and verify A, not ownerNot executed: no original report was created.
⚠️
Check reload persistenceNot executed: reload is prohibited by the test-session policy.
⚠️

Preliminary analysis

Likely mechanism: The report’s stored next-step actor can become stale after the workspace approver changes. This is supported by code, but remains unconfirmed for the reported incident.

Code evidence and alternatives considered
  1. Re-enabling approvals explicitly supplies the workspace owner as the initial approver: WorkflowsApprovalsTab.tsx:333–347.
  2. Toggling rebuilds submitted reports’ stored nextStep: Policy.ts:1215–1274.
  3. Subsequently selecting A updates approval configuration without a corresponding client-side report refresh: Workflow.ts:213–258.
  4. The normal banner path returns the stored report field rather than recalculating its actor: NextStepUtils.ts:594–609.

Alternative: The server may actually leave the report assigned to the owner. The banner alone cannot distinguish that from stale presentation; changing its text without checking the actual assignment could misrepresent who can approve.

The owner-default behavior predates Remove getPersonalDetailByEmail usage in getAccountIDsByLogins #5, so discovery during that PR’s QA does not establish regression causality.

Required confirmation: Capture an affected report ID and narrow reproduction time, then compare managerID and nextStep.actorAccountID before and after each settings change and its server response. No sufficiently scoped production evidence was available. A banner-only fix should not be accepted until those values establish whether the defect is display invalidation or actual reassignment.


view run

MelvinBot avatar Nov 10 '26 08:11 MelvinBot

Proposal

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

After disabling workspace approvals (Workflows > Add approvals toggled off), turning approvals back on, and editing the default workflow (Everyone) to set User A as the approver, opening an already-submitted expense report still shows the workspace owner as the approver (Waiting for you to approve expenses) instead of User A.

What is the root cause of that problem?

In src/libs/actions/Policy/Policy.ts (setWorkspaceApprovalMode), src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx (saveApprovalWorkflow), and src/libs/actions/Workflow.ts (updateApprovalWorkflowRules, updatePolicyDefaultApprover, createApprovalWorkflowRules, updateApprovalWorkflow, and createApprovalWorkflow):

  1. Disabling and re-enabling approvals resets employeeList[email].submitsTo and report.nextStep to policy.owner:

    • When approvals are toggled off in WorkflowsApprovalsTab.tsx:139-147, setWorkspaceApprovalMode(..., CONST.POLICY.APPROVAL_MODE.OPTIONAL) (src/libs/actions/Policy/Policy.ts:1191-1210 & 1326-1358) sets submitsTo = policy.owner for every employee in policy.employeeList, deletes all approval workflow rules in ONYXKEYS.COLLECTION.RULE, and updates report.nextStep on all SUBMITTED expense reports.
    • When approvals are toggled back on (WorkflowsApprovalsTab.tsx:333-348), setWorkspaceApprovalMode(policy, policy?.owner ?? '', CONST.POLICY.APPROVAL_MODE.BASIC, ...) sets policy.approvalMode = CONST.POLICY.APPROVAL_MODE.BASIC and policy.approver = policy.owner, and recomputes report.nextStep (Policy.ts:1222-1287) for all SUBMITTED reports to point to the workspace owner (while the backend reassigns report.managerID to the owner).
  2. updateApprovalWorkflowRules / updatePolicyDefaultApprover sends employees: '[]' and leaves employeeList[email].submitsTo stale when the default workflow is edited:

    • When the owner then edits the default workflow (Everyone) in WorkspaceWorkflowsApprovalsEditPage.tsx:222-244 to set User A as the approver, shouldUseApprovalWorkflowRules (src/libs/WorkflowUtils.ts:1588-1613) returns true (because approvalMode === CONST.POLICY.APPROVAL_MODE.BASIC under MULTIPLE_APPROVERS), so saveApprovalWorkflow calls updateApprovalWorkflowRules (src/libs/actions/Workflow.ts:418-462) rather than updateApprovalWorkflow.
    • Inside updateApprovalWorkflowRules (and createApprovalWorkflowRules), setApprovalWorkflowRules writes ReportSubmit / ReportApprove rules, and then calls updatePolicyDefaultApprover(approvalWorkflow, policy) (src/libs/actions/Workflow.ts:387-405).
    • However, updatePolicyDefaultApprover only merges {approver: newDefaultApprover} into ONYXKEYS.COLLECTION.POLICY and calls WRITE_COMMANDS.UPDATE_WORKSPACE_APPROVAL with employees: '[]' (an empty array) instead of updating employeeList (submitsTo: newDefaultApprover) for the default workflow's members. Because every member's employeeList[email].submitsTo was explicitly set to policy.owner when approvals were disabled, leaving employeeList untouched (and sending employees: '[]' to UpdateWorkspaceApproval) keeps employeeList[email].submitsTo === policy.owner and prevents UpdateWorkspaceApproval from reassigning the submitted report's approver on the backend.
  3. Workflow save actions in src/libs/actions/Workflow.ts do not recompute report.nextStep (or report.managerID) for existing SUBMITTED expense reports:

    • Unlike setWorkspaceApprovalMode in src/libs/actions/Policy/Policy.ts:1222-1287, neither the rules-based workflow actions (updateApprovalWorkflowRules, createApprovalWorkflowRules, removeApprovalWorkflowRules) nor the employeeList-based workflow actions (updateApprovalWorkflow, createApprovalWorkflow, removeApprovalWorkflow) in src/libs/actions/Workflow.ts iterate over ReportUtils.getAllPolicyReports(policy.id) (statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED) to recompute report.nextStep via buildOptimisticNextStep (and report.managerID via getSubmitToAccountID) using the updated policy and rules.

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

  1. In src/libs/actions/Workflow.ts (updatePolicyDefaultApprover):

    • When approvalWorkflow.isDefault is true and newDefaultApprover !== previousDefaultApprover, update submitsTo: newDefaultApprover in policy.employeeList for the members in approvalWorkflow.members (and self-submit for newDefaultApprover, matching updateApprovalWorkflow lines 179-194) and pass the updated employees JSON payload to WRITE_COMMANDS.UPDATE_WORKSPACE_APPROVAL (instead of employees: '[]'), with matching optimisticData, successData, and failureData rollback on ONYXKEYS.COLLECTION.POLICY.
  2. In src/libs/actions/Workflow.ts (updateApprovalWorkflowRules, createApprovalWorkflowRules, removeApprovalWorkflowRules, updateApprovalWorkflow, createApprovalWorkflow, removeApprovalWorkflow):

    • Extract a shared helper buildActiveSubmittedReportsNextStepUpdates({policy: updatedPolicy, rules: updatedRules, ...}) (mirroring setWorkspaceApprovalMode in src/libs/actions/Policy/Policy.ts:1222-1287).
    • For every submitted expense report on the policy (ReportUtils.getAllPolicyReports(policy.id).filter((report) => !!report && ReportUtils.isExpenseReport(report) && report.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED)), compute:
      • nextStep via buildOptimisticNextStep({report, policy: updatedPolicy, rules: updatedRules, predictedNextStatus: CONST.REPORT.STATUS_NUM.SUBMITTED, ...})
      • managerID via getSubmitToAccountID(updatedPolicy, report, ownerLogin, updatedRules)
    • Include the ONYXKEYS.COLLECTION.REPORT updates (nextStep, managerID, and pendingFields.nextStep) in optimisticData, successData, and failureData.

What alternative solutions did you explore? (Optional)

Computing nextStep dynamically at render time in MoneyRequestReportView / ReportHeader without persisting report.nextStep in Onyx was considered, but setWorkspaceApprovalMode (src/libs/actions/Policy/Policy.ts:1222-1287) already establishes the pattern of updating report.nextStep in Onyx optimistic/success/failure data so offline state and LHN/report headers stay consistent.

khoap1220-hue avatar Nov 10 '26 09:11 khoap1220-hue

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01ca8ad8ce36b9eceb

Proposal

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

After turning workspace approvals off and then turning them back on and setting User A as the approver, opening an already-submitted expense report continues to show the workspace owner as the approver in the Next Step section instead of User A.

What is the root cause of that problem?

This issue involves two compounding gaps in src/libs/actions/Policy/Policy.ts and src/libs/actions/Workflow.ts:

  1. updatePolicyDefaultApprover omits employeeList updates when the default workflow is reconfigured: When approvals are turned off, setWorkspaceApprovalMode (src/libs/actions/Policy/Policy.ts) sets all members' employeeList[email].submitsTo to policy.owner and updates report.nextStep on submitted reports to the owner. When the owner re-enables approvals and assigns User A as the default approver, updateApprovalWorkflowRules calls updatePolicyDefaultApprover (src/libs/actions/Workflow.ts). However, updatePolicyDefaultApprover only updates {approver: newDefaultApprover} on the policy and sends an empty array employees: '[]' to WRITE_COMMANDS.UPDATE_WORKSPACE_APPROVAL. It does not update employeeList[email].submitsTo = newDefaultApprover. Consequently, members' submitsTo remains set to policy.owner.

  2. Workflow actions in Workflow.ts do not recompute report.nextStep on existing submitted reports: Unlike setWorkspaceApprovalMode in Policy.ts, the workflow update functions in src/libs/actions/Workflow.ts (updateApprovalWorkflowRules, createApprovalWorkflowRules, updateApprovalWorkflow) do not recompute report.nextStep for existing submitted expense reports on the policy (ReportUtils.getAllPolicyReports(policy.id).filter(r => isExpenseReport(r) && r.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED)). As a result, previously submitted expense reports continue to hold the stale cached nextStep from the disable step pointing to the owner.

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

  1. Update employeeList in src/libs/actions/Workflow.ts (updatePolicyDefaultApprover): When updating the default approver, update submitsTo: newDefaultApprover in policy.employeeList for all members in the default workflow (matching the self-submit and member assignment logic in updateApprovalWorkflow) and send the updated employees list in the WRITE_COMMANDS.UPDATE_WORKSPACE_APPROVAL payload.

  2. Recompute nextStep for active submitted reports in src/libs/actions/Workflow.ts: In updateApprovalWorkflowRules, createApprovalWorkflowRules, and updateApprovalWorkflow: Query active submitted reports on the policy:

    const submittedReports = ReportUtils.getAllPolicyReports(policy.id).filter(
        (report) => ReportUtils.isExpenseReport(report) && report?.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED,
    );
    

    For each report, recompute:

    • nextStep via buildOptimisticNextStep(...) with the updated policy, employee list, and rules.
    • managerID via getSubmitToAccountID(...). Add the updated nextStep and managerID to reportsOptimisticData and reportsSuccessData on ${ONYXKEYS.COLLECTION.REPORT}${report.reportID} (mirroring setWorkspaceApprovalMode).
  3. Regression Tests: Add test in tests/actions/IOUTest/ReportWorkflowTest.ts verifying that disabling approvals, re-enabling approvals, and assigning a new default approver immediately updates nextStep on existing submitted expense reports to the new approver.

What alternative solutions did you explore? (Optional)

Evaluating nextStep dynamically solely inside MoneyRequestReportView without persisting to Onyx was considered, but persisting report.nextStep in Onyx is required by Expensify architectural standards so that offline mode and Push Notifications remain consistent.

jmquero92 avatar Nov 10 '26 11:11 jmquero92

:warning: Unable to store contributor details

Details
Auth SetContributorDetails returned an error
401 Contributor details already exist

melvin-bot[bot] avatar Nov 10 '26 11:11 melvin-bot[bot]

Proposal

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

After workspace approvals are switched off and back on, and the default workflow (Everyone) is edited to set User A as the approver, an already-submitted expense report still shows the workspace owner as the approver in its Next Step section ("Waiting for you to approve expenses") instead of User A.

What is the root cause of that problem?

Two compounding gaps, both verified against main:

  1. Disabling approvals pins every member to the owner, and re-enabling never unpins them. setWorkspaceApprovalMode in src/libs/actions/Policy/Policy.ts:1196-1197 sets submitsTo = policy.owner for every employee when approvals are turned off, and recomputes report.nextStep for submitted reports to point at the owner. When the default workflow is later edited, the save goes through the rules path (shouldUseApprovalWorkflowRules returns true for BASIC mode, src/libs/WorkflowUtils.ts), so updateApprovalWorkflowRules calls updatePolicyDefaultApprover (src/libs/actions/Workflow.ts:387-413). That function only merges {approver: newDefaultApprover} into ONYXKEYS.COLLECTION.POLICY and calls UPDATE_WORKSPACE_APPROVAL with employees: '[]'. Nothing ever writes submitsTo: newDefaultApprover back into policy.employeeList, so every member keeps submitting to the owner and the backend has no employee change to apply.

  2. No workflow-save action recomputes nextStep for existing submitted reports. src/libs/actions/Workflow.ts contains no reference to nextStep or buildOptimisticNextStep at all, unlike setWorkspaceApprovalMode (Policy.ts:1222-1287), which recomputes it. So even after the approver is corrected in policy, already-submitted reports keep the stale nextStep (and managerID) pointing at the owner until something else touches them.

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

A minimal fix in src/libs/actions/Workflow.ts, without refactoring all six workflow actions:

  1. In updatePolicyDefaultApprover, when approvalWorkflow.isDefault and the approver changed, build the employees payload from the default workflow's members with submitsTo: newDefaultApprover (self-submit for the new approver, mirroring updateApprovalWorkflow), pass it to UPDATE_WORKSPACE_APPROVAL instead of employees: '[]', and add matching optimistic/failure data for POLICY.employeeList so the change is visible offline and rolls back on failure.
  2. In updateApprovalWorkflowRules (and createApprovalWorkflowRules for the default workflow), after the rules write, recompute nextStep via buildOptimisticNextStep and managerID via getSubmitToAccountID for the policy's submitted expense reports whose managerID still points at the previous default approver, and include those ONYXKEYS.COLLECTION.REPORT updates in optimistic/success/failure data. Scoping to reports owned by the previous approver keeps the change small and avoids touching unrelated reports.

What alternative solutions did you explore? (Optional)

A shared helper extracting the setWorkspaceApprovalMode recompute loop across all six workflow actions in Workflow.ts was considered, but it is a larger refactor for this bug; the scoped fix above covers the reported flow (off, on, edit default workflow) and the default-workflow create path. Computing nextStep dynamically at render time was also considered, but setWorkspaceApprovalMode already establishes the pattern of persisting nextStep in Onyx so offline state and headers stay consistent.

Tests

  1. Unit test for updatePolicyDefaultApprover: a default-workflow approver change sends a non-empty employees payload with submitsTo set to the new approver, and employeeList optimistic data reflects it.
  2. Workflow test for the reported flow: approvals off, approvals on, edit default workflow to User A, with a submitted expense report present; assert the report's nextStep names User A and managerID equals User A's account ID.
  3. Manual: reproduce the issue steps on staging and confirm the submitted report shows "Waiting for User A to approve expenses"; confirm a report submitted after the fix shows the same without any toggle cycle.

Contributor details

Your Expensify account email: [email protected]

Upwork Profile Link: https://www.upwork.com/freelancers/~01c5c6bc0e7d162f7b

khizzcr7 avatar Nov 10 '26 12:11 khizzcr7

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 10 '26 12:11 melvin-bot[bot]

@MelvinBot Investigate whether this issue is coming from the PR mentioned in the issue's description, if not find the root cause and write-up a formal proposal.

ikevin127 avatar Nov 10 '26 21:11 ikevin127

Proposal

PR attribution: I found a pre-existing client-side defect that explains a stale approver banner. The evidence does not establish that Remove getPersonalDetailByEmail usage in getAccountIDsByLogins #5 introduced this issue. However, conclusively ruling it out still requires a before/after reproduction because it changes the personal-details lookup source.

What is the root cause of that problem?

The displayed approver can remain stale after workflow settings change. Approval toggling refreshes existing reports’ stored nextStep, but subsequently saving another approver updates policy/rules without refreshing those reports. The ordinary banner continues displaying the cached actor.

I reproduced this client inconsistency with a controlled test: after saving A, the policy and report assignment both identified A, while the displayed next step still identified the owner.

Confidence: medium for explaining this incident; confirmed for the controlled client case. The affected production report’s actual assignment remains unknown.

Evidence, PR comparison, and verification
  • Before the linked PR, re-enabling approvals already selected the owner: WorkflowsApprovalsTab.tsx:329–342. The submitted-report refresh also already existed: Policy.ts:1214–1284.
  • Workflow-save code was unchanged by that merge. It saves rules/default approver without refreshing existing reports: Workflow.ts:387–462.
  • The ordinary banner returns cached report.nextStep: NextStepUtils.ts:594–609.
  • Actual approval eligibility checks managerID, independently of the banner: ReportUtils.ts:3476–3483.
  • Three selected existing tests and two temporary, uncommitted diagnostic tests passed. The diagnostic tests demonstrated the stale banner and a separate policy-snapshot inconsistency. They did not reproduce the complete server-backed toggle sequence.
  • The earlier web attempt was blocked by the second-member precondition. No successful browser reproduction or production assignment capture is available.

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

For the confirmed display inconsistency, keep the ordinary pending-approval banner consistent with the report’s current assignment:

  1. In the next-step selection path, correct a mismatched cached approver using a valid report.managerID, narrowly scoped to ordinary submitted expense reports awaiting approval. Preserve existing special-case banners and workflow overrides.
  2. Add regression tests covering manager=A/banner=owner, manager=owner, subsequent assignment updates, different viewers, takeover/forwarding, and invalid manager data.

This avoids changing approval authority merely to repair its presentation.

Validation gate: Capture the affected report’s managerID and nextStep.actorAccountID after the final save and server response. If both identify the owner, this display correction is not the complete solution; the assignment behavior requires separate investigation before implementation.

What alternative solutions did you explore? (Optional)

  • Rewrite every submitted report’s managerID: unsafe without confirming server semantics; it can overwrite intentional reassignment.
  • Populate employees instead of sending an empty array: not established as necessary. Rules-based routing can override legacy employee routing, so an empty employee payload does not prove broken assignment.
  • Recompute from the latest policy alone: can display a configured approver who is not the report’s actual assignee.

Next Steps for Contributor+ team: Confirm the affected report’s assignment before accepting an implementation scope.
To refine: @MelvinBot <your feedback>


view run

MelvinBot avatar Nov 10 '26 21:11 MelvinBot

🔴 Proposal 1 (MelvinBot): I can't accept this yet. The live repro shows a different root cause than the one in the proposal.

I reproduced this on web. After the final save (approvals off, then on, then A set as default approver again), the submitted report has:

  • policy.approver: A
  • report.managerID: owner
  • report.nextStep.actorAccountID: owner

So the report really is assigned to the owner. The banner isn't just stale. That's the case your validation gate describes, and the managerID-based banner correction would still show the owner. setWorkspaceApprovalMode never writes managerID on the client, so the backend reassigns submitted reports to the owner when approvals are disabled. updatePolicyDefaultApprover then calls UpdateWorkspaceApproval, and that call doesn't move them back to the new default approver.

Your note on employees: '[]' holds up. Before the toggle, every member's employeeList[].submitsTo was already the owner, yet the report still went to A on submit. That means the rules-based routing decides the assignment, and the empty employees payload isn't what blocks it.

There are two possible outcomes. Either reports that are already submitted should follow the new default approver, which looks like a backend change, or the owner keeping them after an approvals off/on cycle is expected.


I can reproduce this on web. Here's what I did:

  1. In a workspace with approvals on, set member A as the default approver.
  2. Submit an expense to the workspace chat. The next step shows "Waiting for A to approve expenses."
  3. Go to Workflows > Approvals, turn approvals off, then turn them back on. The default approver resets to the owner.
  4. Edit the default workflow, set A as the approver again and save.
  5. Open the submitted report from the workspace chat. The next step now shows "Waiting for you to approve expenses."

After step 5 the report data shows policy.approver as A, but report.managerID and report.nextStep.actorAccountID both point to the owner. So the report is actually assigned to the owner, not just showing a stale banner. The client never writes managerID when approvals are toggled, which means the backend moves submitted reports to the owner on disable. Setting the default approver afterwards (UpdateWorkspaceApproval) doesn't move them back.

I see two possible outcomes:

  1. Reports that are already submitted should follow the new default approver. That looks like a backend change in UpdateWorkspaceApproval (or in how re-enabling approvals handles submitted reports), with the client only updating nextStep/managerID optimistically.
  2. The owner keeping those reports after an approvals off/on cycle is expected, and only reports submitted after the change should go to A. In that case the current behavior is correct and we can close this.

@AndrewGable Could you confirm which one is expected before we move on with an implementation ?

🎀👀🎀 C+ reviewed

ikevin127 avatar Nov 10 '26 23:11 ikevin127

Triggered auto assignment to @AndrewGable, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Nov 10 '26 23:11 melvin-bot[bot]

Proposal

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

In workspace approval settings, after toggling approval mode back and forth, the right/correct approver is not displayed in the approver field.

What is the root cause of that problem?

In src/pages/workspace/workflows/WorkspaceWorkflowsApprovalsPage.tsx and src/libs/actions/Policy/Policy.ts: When switching approval modes (e.g. from Advanced to Basic or vice versa), the local state or optimistic update clears defaultApprover from the policy draft object without restoring the saved approver email from the policy Onyx data policy.approver. The selector falls back to an empty string instead of the workspace owner or previously configured default approver.

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

  1. In src/pages/workspace/workflows/WorkspaceWorkflowsApprovalsPage.tsx:
    • When switching back approval mode, read the active policy?.approver ?? policy?.owner as the initial fallback value rather than defaulting to empty.
  2. In src/libs/actions/Policy/Policy.ts (setApprovalMode):
    • Preserve defaultApprover in the optimistic data payload when reverting approval modes so the UI remains consistent before and after API response.

What alternative solutions did you explore? (Optional)

Forcing a full policy refetch on every toggle, which introduces unnecessary network latency and UI flickering.

TassioSales avatar Nov 11 '26 13:11 TassioSales

@AndrewGable Still overdue 6 days?! Let's take care of this!

@AndrewGable 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

@AndrewGable @ikevin127 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@AndrewGable 12 days overdue now... This issue's end is nigh!