Skip to content

[Due for payment 2026-08-29] [$250] Approval workflow mismatch between New Expensify and Old Expensify causes report submission failure #94891

Closed

Description

@m-natarajan

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


Version Number:
Reproducible in staging?: Needs Reproduction (Unable to reproduce)
Reproducible in production?: Needs Reproduction
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @jowennlucero
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Configure the approval workflow so all employees report to User A.
  2. Verify the workflow in New Expensify (ND).
  3. Verify the same member's approver in Old Expensify (OD).
  4. Observe that the member (User B) still has a previous employee configured as their approver in OD.
  5. As User B, submit a report in ND.

Expected Result:

The approval workflow should be consistent between OD and ND.
User B's approver should be User A in both systems.
Report submission in ND should succeed using the updated approval workflow.

Actual Result:

ND correctly shows User A as User B's approver.
OD still retains a previous employee as User B's approver.
The mismatch causes ND to throw an error when User B submits a report.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

The screenshot for the issue is in Slack thread

View all open jobs on GitHub

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 29, 2026
  2. exfy-zapier commented on Jun 29, 2026

    @exfy-zapier

    This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 29, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 29, 2026
  5. lorretheboy commented on Jun 29, 2026

    @lorretheboy
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-06-29 19:28:19 UTC.

    Proposal

    What is the root cause of that problem?

    On submit, ND resolves User B's approver through getSubmitReportManagerAccountID → getSubmitToAccountID → getManagerAccountID:

    App/src/libs/PolicyUtils.ts

    Lines 1573 to 1592 in 552b726

    function getManagerAccountID(policy: OnyxEntry<Policy>, ownerLogin: string | undefined) {
    const managerEmail = getManagerAccountEmail(policy, ownerLogin);
    return managerEmail ? (getAccountIDsByLogins([managerEmail]).at(0) ?? -1) : -1;
    }
    /**
    * Returns the accountID to whom the given expenseReport submits reports to in the given Policy.
    */
    function getSubmitToAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>, ownerLogin: string | undefined): number {
    const approvalRules = policy?.rules?.approvalRules;
    if (!isSubmitAndClose(policy) && approvalRules?.length) {
    const ruleApprover = getFirstRuleApprover(approvalRules, expenseReport, ownerLogin);
    if (ruleApprover) {
    return getAccountIDsByLogins([ruleApprover]).at(0) ?? -1;
    }
    }
    return getManagerAccountID(policy, ownerLogin);
    }

    getManagerAccountEmail correctly returns User A's email. The bug is in the email→ID conversion: getManagerAccountID uses getAccountIDsByLogins, which fabricates an accountID via generateAccountID whenever the email has no cached personal detail — true for a freshly-configured approver the submitter has never loaded:

    function getAccountIDsByLogins(logins: string[]): number[] {
    return logins.reduce<number[]>((foundAccountIDs, login) => {
    const currentDetail = getPersonalDetailByEmail(login);
    if (!currentDetail) {
    // generate an account ID because in this case the detail is probably new, so we don't have a real accountID yet
    foundAccountIDs.push(generateAccountID(login));
    } else {
    foundAccountIDs.push(Number(currentDetail.accountID));
    }
    return foundAccountIDs;
    }, []);
    }

    generateAccountID is a positive hash, and isValidAccountRoute only checks accountID > 0, so the synthetic value is accepted as valid:

    function isValidAccountRoute(accountID: number): boolean {
    return CONST.REGEX.NUMBER.test(String(accountID)) && accountID > 0;
    }

    In getSubmitReportManagerAccountID, hasReliablePolicyRoute is true (User B is in employeeList) and isValidSubmitToAccountID is true (the hash is positive), so the first branch returns the fabricated accountID as a "reliable" route:

    App/src/libs/PolicyUtils.ts

    Lines 1594 to 1616 in 552b726

    function getSubmitReportManagerAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>, submitterLogin: string | undefined): number | undefined {
    const ownerAccountID = expenseReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID;
    const existingManagerID = expenseReport?.managerID;
    const approvalRules = policy?.rules?.approvalRules;
    const ruleApprover = !isSubmitAndClose(policy) && approvalRules?.length ? getFirstRuleApprover(approvalRules, expenseReport, submitterLogin) : '';
    const submitToAccountID = getSubmitToAccountID(policy, expenseReport, submitterLogin);
    const isValidSubmitToAccountID = isValidAccountRoute(submitToAccountID);
    const isValidExistingManagerID = isValidAccountRoute(existingManagerID ?? CONST.DEFAULT_NUMBER_ID) && existingManagerID !== ownerAccountID;
    const hasReliablePolicyRoute =
    ([CONST.POLICY.APPROVAL_MODE.OPTIONAL, CONST.POLICY.APPROVAL_MODE.BASIC] as Array<ValueOf<typeof CONST.POLICY.APPROVAL_MODE>>).includes(getApprovalWorkflow(policy)) ||
    !!ruleApprover ||
    !!policy?.employeeList?.[submitterLogin ?? ''];
    if (hasReliablePolicyRoute && isValidSubmitToAccountID) {
    return submitToAccountID;
    }
    if (!hasReliablePolicyRoute && isValidExistingManagerID) {
    return existingManagerID;
    }
    return isValidSubmitToAccountID ? submitToAccountID : existingManagerID;
    }

    submitReport then sends that fabricated managerAccountID to SUBMIT_REPORT:

    const parameters: SubmitReportParams = {
    reportID: expenseReport.reportID,
    managerAccountID: managerID,
    reportActionID: optimisticSubmittedReportAction.reportActionID,
    };
    onSubmitted?.();
    API.write(WRITE_COMMANDS.SUBMIT_REPORT, parameters, {optimisticData, successData, failureData});

    So the chain is: approver email resolves correctly → it's converted to a hashed fake accountID because User A isn't in the submitter's personalDetails → the fake passes isValidAccountRoute → it's sent as managerAccountID → the backend can't match the hash to a real policy member and rejects the submission. ND still displays User A correctly because the UI resolves the approver by email, which masks the bad ID and makes it look like an OD/ND mismatch.

    Note this is specifically the fabricated-ID case for a correctly-configured approver — distinct from submitsTo pointing at a non-member. In the reported scenario ND shows User A as the approver, i.e. employeeList[UserB].submitsTo already resolves to User A (a current member); the only thing wrong is the synthesized accountID.

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

    Do not send a fabricated approver accountID on submit. managerAccountID is already optional in SubmitReportParams, and getSubmitReportManagerAccountID can already return undefined — when the resolved approver is not a real, cached account, omit it and let the backend authoritatively resolve the approver from the policy (it has the report owner and the policy's approval config):

    type SubmitReportParams = {
    reportID: string;
    managerAccountID?: number;
    reportActionID: string;
    };
    export default SubmitReportParams;

    Concretely, in getSubmitReportManagerAccountID, gate the "reliable route" on the approver being a real account rather than merely passing isValidAccountRoute (which a positive hash satisfies). Resolve the approver email already computed in scope (ruleApprover, else getManagerAccountEmail(policy, submitterLogin)) and treat the route as valid only when getPersonalDetailByEmail(email)?.accountID exists; otherwise return undefined so SUBMIT_REPORT is sent without a managerAccountID:

    App/src/libs/PolicyUtils.ts

    Lines 1594 to 1616 in 552b726

    function getSubmitReportManagerAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>, submitterLogin: string | undefined): number | undefined {
    const ownerAccountID = expenseReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID;
    const existingManagerID = expenseReport?.managerID;
    const approvalRules = policy?.rules?.approvalRules;
    const ruleApprover = !isSubmitAndClose(policy) && approvalRules?.length ? getFirstRuleApprover(approvalRules, expenseReport, submitterLogin) : '';
    const submitToAccountID = getSubmitToAccountID(policy, expenseReport, submitterLogin);
    const isValidSubmitToAccountID = isValidAccountRoute(submitToAccountID);
    const isValidExistingManagerID = isValidAccountRoute(existingManagerID ?? CONST.DEFAULT_NUMBER_ID) && existingManagerID !== ownerAccountID;
    const hasReliablePolicyRoute =
    ([CONST.POLICY.APPROVAL_MODE.OPTIONAL, CONST.POLICY.APPROVAL_MODE.BASIC] as Array<ValueOf<typeof CONST.POLICY.APPROVAL_MODE>>).includes(getApprovalWorkflow(policy)) ||
    !!ruleApprover ||
    !!policy?.employeeList?.[submitterLogin ?? ''];
    if (hasReliablePolicyRoute && isValidSubmitToAccountID) {
    return submitToAccountID;
    }
    if (!hasReliablePolicyRoute && isValidExistingManagerID) {
    return existingManagerID;
    }
    return isValidSubmitToAccountID ? submitToAccountID : existingManagerID;
    }

    Crucially, keep this scoped to the submit path. Do not change getManagerAccountID globally: it feeds the optimistic managerID at report creation and many read-only display utilities (report-preview/primary/secondary actions, OptionsList, Search), which legitimately rely on the generated placeholder ID to render an approver who is a real but not-yet-cached new member:

    App/src/libs/ReportUtils.ts

    Lines 6805 to 6811 in 552b726

    lastVisibleActionCreated: timeOfCreation,
    pendingFields: {createReport: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD},
    parentReportID: parentReport?.reportID,
    parentReportActionID,
    chatReportID: parentReport?.reportID,
    managerID: getManagerAccountID(policy, login),
    };

    Because getSubmitReportManagerAccountID is the single convergence point every submit flow uses, omitting the unreliable managerAccountID there fixes submission for all callers while leaving optimistic display behavior untouched. ND then submits User B's report and the backend routes it to the just-updated approver (User A), matching the Expected Result.

    What alternative solutions did you explore? (Optional)

    • Change getManagerAccountID itself to return a real-or--1 value (getPersonalDetailByEmail(managerEmail)?.accountID ?? -1, or pass a "don't generate" flag into getAccountIDsByLogins) and additionally extend SubmitReportParams to carry the approver email so the backend can map email → policy member. This fixes the fabrication at the source, but it broadens the surface to every getManagerAccountID/getSubmitToAccountID caller (risking the optimistic-managerID and display regressions noted above for legitimately-new members) and depends on a backend change to accept/prefer the new email param. The scoped omit-on-submit fix above avoids both.

    • Guard the resolution against a submitsTo that no longer references a current employeeList member and fall back to the policy default approver. This addresses a different failure mode (orphaned/stale submitsTo), but in the reported case ND already resolves the approver to User A (a current member), so the membership guard never fires — the problem is the synthesized accountID, not an out-of-policy email.

  6. abbasifaizan70 commented on Jun 29, 2026

    @abbasifaizan70
    Contributor

    Proposal

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

    After an admin reconfigures the default approval workflow so that all employees report to a new approver (User A), New Expensify (ND) shows User A as User B's approver, but Old Expensify (OD) still keeps a previously-configured approver for User B. Because OD's submitsTo for User B was never corrected, the two systems disagree, and when User B submits a report the approver resolves to an invalid/stale manager and submission fails.

    What is the root cause of that problem?

    When the workflow editor builds the list of workflow members from the policy's employeeList, any employee whose submitsTo is empty (they implicitly submit to the policy default approver) — or whose submitsTo points at someone no longer present in employeeList — is skipped entirely and never added to any workflow's members array. So an employee like User B, who is relying on the default approver, is not a member of the default workflow.

    if (!submitsTo || (!employees[submitsTo] && !hrAdvancedModeFinalApproverEmail)) {
    continue;
    }

    When the admin saves the changed default workflow, convertApprovalWorkflowToPolicyEmployees only rewrites submitsTo for emails that appear in approvalWorkflow.members. Members that were skipped above are therefore never given an explicit submitsTo = <new default approver>, so nothing is sent to the backend for them and OD's stored value survives the change.

    for (const {email} of approvalWorkflow.members) {
    const submitsTo = type === CONST.APPROVAL_WORKFLOW.TYPE.REMOVE ? '' : (firstApprover.email ?? '');
    // For every member, we check if the submitsTo field has changed.
    // If it has, we update the employee list with the new submitsTo value.
    if (previousEmployeeList[email]?.submitsTo === submitsTo) {
    continue;
    }
    updatedEmployeeList[email] = {
    ...(updatedEmployeeList[email] ? updatedEmployeeList[email] : {email}),
    submitsTo,
    pendingAction,
    pendingFields: {
    submitsTo: pendingAction,
    },
    };
    }

    There is already a backstop in updateApprovalWorkflow, but it only fixes the single newly-promoted default approver's own submitsTo; it does not sweep the other implicit-default members, which is exactly the population that goes stale here.

    // Force the new default approver's `submitsTo` to themselves whenever the default
    // approver changes. `convertApprovalWorkflowToPolicyEmployees` only rewrites `submitsTo`
    // for emails present in `approvalWorkflow.members`, so a newly-promoted approver who
    // wasn't already a member (e.g., an agent the backend's `shareWithEmployees` just added
    // with `submitsTo = previous default approver`) keeps that stale value and shows up as
    // their own orphan submission group on the workflows page. This backstop guarantees the
    // new default approver self-submits regardless of the caller's `members` snapshot.
    if (newDefaultApprover && newDefaultApprover !== previousDefaultApprover) {
    const existing = updatedEmployees[newDefaultApprover] ?? previousEmployeeList[newDefaultApprover];
    if (existing && existing.submitsTo !== newDefaultApprover) {
    const previousPendingAction = previousEmployeeList[newDefaultApprover]?.pendingAction;
    updatedEmployees[newDefaultApprover] = {
    ...existing,
    email: newDefaultApprover,
    submitsTo: newDefaultApprover,
    pendingAction: previousPendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? previousPendingAction : CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    pendingFields: {
    ...existing.pendingFields,
    submitsTo: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    },
    };
    }
    }

    Finally, this is why submission breaks: ND resolves the report's manager from employee?.submitsTo ?? defaultApprover. ND shows User A because User B's local submitsTo is empty and falls back to the (new) default approver, while OD submits using its own stale submitsTo (the previous employee), so the manager resolves inconsistently/invalidly.

    App/src/libs/PolicyUtils.ts

    Lines 1549 to 1554 in fd2b949

    const employee = policy?.employeeList?.[employeeLogin];
    if (!employee && !defaultApprover) {
    return -1;
    }
    return getAccountIDsByLogins([employee?.submitsTo ?? defaultApprover]).at(0) ?? -1;

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

    When the default approver changes, every policy member who implicitly submits to the old default approver (empty submitsTo, or submitsTo equal to the previous default approver) must be given an explicit submitsTo = newDefaultApprover so the correcting update is actually sent to the backend — not just the new approver themselves. Extend the existing backstop in updateApprovalWorkflow from a single-employee fix into a sweep over previousEmployeeList.

    // Force the new default approver's `submitsTo` to themselves whenever the default
    // approver changes. `convertApprovalWorkflowToPolicyEmployees` only rewrites `submitsTo`
    // for emails present in `approvalWorkflow.members`, so a newly-promoted approver who
    // wasn't already a member (e.g., an agent the backend's `shareWithEmployees` just added
    // with `submitsTo = previous default approver`) keeps that stale value and shows up as
    // their own orphan submission group on the workflows page. This backstop guarantees the
    // new default approver self-submits regardless of the caller's `members` snapshot.
    if (newDefaultApprover && newDefaultApprover !== previousDefaultApprover) {
    const existing = updatedEmployees[newDefaultApprover] ?? previousEmployeeList[newDefaultApprover];
    if (existing && existing.submitsTo !== newDefaultApprover) {
    const previousPendingAction = previousEmployeeList[newDefaultApprover]?.pendingAction;
    updatedEmployees[newDefaultApprover] = {
    ...existing,
    email: newDefaultApprover,
    submitsTo: newDefaultApprover,
    pendingAction: previousPendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? previousPendingAction : CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    pendingFields: {
    ...existing.pendingFields,
    submitsTo: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    },
    };
    }
    }

    if (newDefaultApprover && newDefaultApprover !== previousDefaultApprover) {
      for (const [email, employee] of Object.entries(previousEmployeeList)) {
        // Members who implicitly submit to the old default approver (empty submitsTo) or who still
        // point at the previous default approver are absent from approvalWorkflow.members, so
        // convertApprovalWorkflowToPolicyEmployees never rewrites them. Without this sweep their
        // submitsTo stays stale on the backend (OD) while ND shows the new default approver,
        // and report submission resolves to an invalid manager.
        const submitsToDefault =
          !employee.submitsTo || employee.submitsTo === previousDefaultApprover;
        if (!submitsToDefault || updatedEmployees[email]) {
          continue;
        }
    
        const previousPendingAction = previousEmployeeList[email]?.pendingAction;
        updatedEmployees[email] = {
          ...employee,
          email,
          submitsTo: newDefaultApprover,
          pendingAction:
            previousPendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
              ? previousPendingAction
              : CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
          pendingFields: {
            ...employee.pendingFields,
            submitsTo: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
          },
        };
      }
    }

    This generalizes the current new-approver-only block (the new default approver is also caught by the sweep, since submitsTo === previousDefaultApprover or empty resolves them to themselves), guaranteeing that every implicit-default member gets an explicit submitsTo written and pushed to the backend, keeping OD and ND consistent and allowing User B to submit successfully.

  7. melvin-bot commented on Jun 29, 2026

    @melvin-bot

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

  8. changed the title [-]Approval workflow mismatch between New Expensify and Old Expensify causes report submission failure[/-] [+][$250] Approval workflow mismatch between New Expensify and Old Expensify causes report submission failure[/+] on Jun 29, 2026
  9. melvin-bot commented on Jun 29, 2026

    @melvin-bot
  10. yusufdeveloper2903 commented on Jun 29, 2026

    @yusufdeveloper2903
    Contributor

    Proposal

    What is the root cause of that problem?

    When an expense report is submitted, ND resolves the approver (the report's managerID) through getSubmitToAccountID → getManagerAccountID. For an Advanced approval workflow, getManagerAccountID resolves the approver straight from the submitter's stored submitsTo, with the only fallback being the case where submitsTo is empty:

    App/src/libs/PolicyUtils.ts

    Lines 1539 to 1554 in 05d32d5

    function getManagerAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report> | {ownerAccountID: number}) {
    const employeeAccountID = expenseReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID;
    const employeeLogin = getLoginByAccountID(employeeAccountID) ?? '';
    const defaultApprover = getDefaultApprover(policy);
    // For policy using the optional or basic workflow, the manager is the policy default approver.
    if (([CONST.POLICY.APPROVAL_MODE.OPTIONAL, CONST.POLICY.APPROVAL_MODE.BASIC] as Array<ValueOf<typeof CONST.POLICY.APPROVAL_MODE>>).includes(getApprovalWorkflow(policy))) {
    return getAccountIDsByLogins([defaultApprover]).at(0) ?? -1;
    }
    const employee = policy?.employeeList?.[employeeLogin];
    if (!employee && !defaultApprover) {
    return -1;
    }
    return getAccountIDsByLogins([employee?.submitsTo ?? defaultApprover]).at(0) ?? -1;

    return getAccountIDsByLogins([employee?.submitsTo ?? defaultApprover]).at(0) ?? -1;

    The problem is that employee.submitsTo is trusted without checking that it still references a current member of the policy. In this bug, User B's policy.employeeList[UserB].submitsTo still points at a previous employee (someone who was their approver before the workflow was reconfigured and is no longer in the workspace). Because that email is non-empty, the ?? defaultApprover fallback never fires, and getAccountIDsByLogins happily turns the orphaned email into an account ID — for an email with no personal detail it even fabricates one via generateAccountID:

    function getAccountIDsByLogins(logins: string[]): number[] {
    return logins.reduce<number[]>((foundAccountIDs, login) => {
    const currentDetail = getPersonalDetailByEmail(login);
    if (!currentDetail) {
    // generate an account ID because in this case the detail is probably new, so we don't have a real accountID yet
    foundAccountIDs.push(generateAccountID(login));
    } else {
    foundAccountIDs.push(Number(currentDetail.accountID));
    }
    return foundAccountIDs;
    }, []);
    }

    So the report is submitted with a managerID pointing at someone who is not part of the policy's approval chain, and the backend rejects it → the submission error.

    This only happens in Advanced mode. For Optional/Basic workflows the very same function short-circuits to the policy default approver and ignores the member's submitsTo entirely, which is why submission works there:

    App/src/libs/PolicyUtils.ts

    Lines 1544 to 1547 in 05d32d5

    // For policy using the optional or basic workflow, the manager is the policy default approver.
    if (([CONST.POLICY.APPROVAL_MODE.OPTIONAL, CONST.POLICY.APPROVAL_MODE.BASIC] as Array<ValueOf<typeof CONST.POLICY.APPROVAL_MODE>>).includes(getApprovalWorkflow(policy))) {
    return getAccountIDsByLogins([defaultApprover]).at(0) ?? -1;
    }

    The codebase already treats a submitsTo that points to a non-member as "no real approver" everywhere else — when building the workflows view, a member whose submitsTo is missing from employeeList is skipped from every workflow exactly via this !employees[submitsTo] membership check:

    if (!submitsTo || (!employees[submitsTo] && !hrAdvancedModeFinalApproverEmail)) {
    continue;
    }

    getManagerAccountID is the one resolution point that omits that guard.

    So: stale submitsTo → previous employee → getManagerAccountID resolves an out-of-policy managerID → submission fails. This is the single convergence point for submit/forward — every caller (getSubmitToAccountID, getSubmitReportManagerAccountID, the optimistic managerID at ReportUtils.ts#L6805) flows through it.

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

    Reuse the exact membership check the rest of the codebase already uses (policy?.employeeList?.[submitsTo], the same guard as WorkflowUtils.ts#L186) and fall back to defaultApprover — which is already computed in scope at PolicyUtils.ts#L1542 — when submitsTo no longer points to a policy member:

    - return getAccountIDsByLogins([employee?.submitsTo ?? defaultApprover]).at(0) ?? -1;
    + const submitsTo = employee?.submitsTo && policy?.employeeList?.[employee.submitsTo] ? employee.submitsTo : defaultApprover;
    + return getAccountIDsByLogins([submitsTo]).at(0) ?? -1;

    This is the smallest possible surface area and has zero regression risk: a valid submitsTo (current member) is unchanged, an empty submitsTo still falls to defaultApprover as before, and only the orphaned case now routes to the default approver instead of an out-of-policy account. Because getManagerAccountID is the convergence point, fixing it here fixes submit, forward, and the optimistic managerID in one place. ND will then submit User B's report to the updated default approver (User A), matching the Expected Result. Minor refinements can be discussed in the PR phase.

    What alternative solutions did you explore? (Optional)

    Reconciling the stale submitsTo at write time — e.g. having the workflow-reconfiguration path in convertApprovalWorkflowToPolicyEmployees (WorkflowUtils.ts#L393-L410) also emit a reset for members whose submitsTo is orphaned, so the corrected value is pushed to OD. This is a larger, higher-risk change (it touches the API payload of every workflow edit and still wouldn't protect reports whose stale data already exists), whereas guarding getManagerAccountID fixes the actual submission failure at the read/resolution point for all existing data. The two are complementary, but the read-side guard is the minimal, regression-free fix for the reported error.

  11. Abdulloh0109 commented on Jun 29, 2026

    @Abdulloh0109
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-06-29 19:26:11 UTC.

    Proposal

    What is the root cause of that problem?

    The same submitsTo value is read two different ways in ND, and the two disagree — that disagreement is the bug.

    Display path validates the approver. When the Workflows page builds its groups, convertPolicyEmployeesToApprovalWorkflows skips any member whose submitsTo doesn't resolve to a current policy member:

    }
    if (!submitsTo || (!employees[submitsTo] && !hrAdvancedModeFinalApproverEmail)) {
    continue;
    }

    So if User B's submitsTo still points at a "previous employee" who is no longer in employeeList (and there's no HR advanced final approver), User B isn't grouped under that stale approver — they fall through to availableMembers and get folded under the default "Expenses from everyone" workflow, i.e. User A. That's why "ND correctly shows User A".

    Submit path does NOT validate the approver. Report submission resolves the manager through getManagerAccountEmail, which returns the raw submitsTo with no member-existence check:

    App/src/libs/PolicyUtils.ts

    Lines 1557 to 1571 in 552b726

    function getManagerAccountEmail(policy: OnyxEntry<Policy>, ownerLogin: string | undefined): string {
    const defaultApprover = getDefaultApprover(policy);
    // For policy using the optional or basic workflow, the manager is the policy default approver.
    if (([CONST.POLICY.APPROVAL_MODE.OPTIONAL, CONST.POLICY.APPROVAL_MODE.BASIC] as Array<ValueOf<typeof CONST.POLICY.APPROVAL_MODE>>).includes(getApprovalWorkflow(policy))) {
    return defaultApprover;
    }
    const employee = policy?.employeeList?.[ownerLogin ?? ''];
    if (!employee && !defaultApprover) {
    return '';
    }
    return employee?.submitsTo ?? defaultApprover ?? '';
    }

    That feeds straight into the submit chain — getSubmitToAccountID → getManagerAccountID → getManagerAccountEmail:

    App/src/libs/PolicyUtils.ts

    Lines 1581 to 1614 in 552b726

    function getSubmitToAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>, ownerLogin: string | undefined): number {
    const approvalRules = policy?.rules?.approvalRules;
    if (!isSubmitAndClose(policy) && approvalRules?.length) {
    const ruleApprover = getFirstRuleApprover(approvalRules, expenseReport, ownerLogin);
    if (ruleApprover) {
    return getAccountIDsByLogins([ruleApprover]).at(0) ?? -1;
    }
    }
    return getManagerAccountID(policy, ownerLogin);
    }
    function getSubmitReportManagerAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>, submitterLogin: string | undefined): number | undefined {
    const ownerAccountID = expenseReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID;
    const existingManagerID = expenseReport?.managerID;
    const approvalRules = policy?.rules?.approvalRules;
    const ruleApprover = !isSubmitAndClose(policy) && approvalRules?.length ? getFirstRuleApprover(approvalRules, expenseReport, submitterLogin) : '';
    const submitToAccountID = getSubmitToAccountID(policy, expenseReport, submitterLogin);
    const isValidSubmitToAccountID = isValidAccountRoute(submitToAccountID);
    const isValidExistingManagerID = isValidAccountRoute(existingManagerID ?? CONST.DEFAULT_NUMBER_ID) && existingManagerID !== ownerAccountID;
    const hasReliablePolicyRoute =
    ([CONST.POLICY.APPROVAL_MODE.OPTIONAL, CONST.POLICY.APPROVAL_MODE.BASIC] as Array<ValueOf<typeof CONST.POLICY.APPROVAL_MODE>>).includes(getApprovalWorkflow(policy)) ||
    !!ruleApprover ||
    !!policy?.employeeList?.[submitterLogin ?? ''];
    if (hasReliablePolicyRoute && isValidSubmitToAccountID) {
    return submitToAccountID;
    }
    if (!hasReliablePolicyRoute && isValidExistingManagerID) {
    return existingManagerID;
    }

    …and submitReport sends whatever comes out as managerAccountID (there is no client-side guard that rejects it):

    const managerID = getSubmitReportManagerAccountID(policy, expenseReport, submitterLogin);
    const optimisticNextStepApproverID = !isSubmitAndClosePolicy && managerID !== undefined && isValidAccountRoute(managerID) ? managerID : undefined;

    }
    const parameters: SubmitReportParams = {
    reportID: expenseReport.reportID,
    managerAccountID: managerID,
    reportActionID: optimisticSubmittedReportAction.reportActionID,
    };
    onSubmitted?.();
    API.write(WRITE_COMMANDS.SUBMIT_REPORT, parameters, {optimisticData, successData, failureData});

    So all three reported symptoms come from one cause:

    • ND shows User A — display path drops the stale submitsTo and folds User B under the default approver.
    • OD retains the previous employee — that's the raw stored submitsTo the submit path also reads.
    • Submission fails — ND computes managerAccountID = the stale/removed "previous employee" and sends it to SUBMIT_REPORT; the backend rejects it because that approver is no longer a valid member of the policy's approval chain.

    The display already knows the stale approver is invalid and ignores it; the submit path doesn't, so it ships an approver ND itself wouldn't show.

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

    Fix the approver-resolution util so the submit path applies the same validation the display already does.

    In getManagerAccountEmail (PolicyUtils.ts#L1557-L1571), before returning employee.submitsTo, check it still resolves to a current policy member — i.e. policy.employeeList[submitsTo] exists (mirroring the !employees[submitsTo] guard at WorkflowUtils.ts#L186). If it doesn't, fall back to defaultApprover. After this change getSubmitToAccountID/getSubmitReportManagerAccountID send the valid default approver (User A) — the same person the Workflows page shows — so SUBMIT_REPORT routes to a real approver and succeeds.

    Layer choice: this is a selector/util fix, not a render or write-path fix, because the divergence is purely in how the manager is resolved at submit time. Putting it in getManagerAccountEmail covers every caller of the submit chain in one place.

    Edge cases it touches:

    • Advanced multi-level chains where submitsTo is a valid member are unaffected — the guard only triggers when the approver no longer exists.
    • Category/tag rule approvers are unaffected — getSubmitToAccountID already resolves those first and only falls back to getManagerAccountID.
    • The existing ?? defaultApprover fallback stays, so submit-and-close/basic/optional behavior is unchanged.

    One honest boundary: this assumes the backend honors the managerAccountID ND passes to SUBMIT_REPORT (which is why ND computes and sends it, and matches the issue's Expected Result). The leftover OD↔ND display mismatch — OD still storing the old submitsTo — is a separate, now-harmless data cosmetic; it no longer blocks submission once ND sends a valid approver. If we also want OD's stored value reconciled, that's a backend-owned cleanup (see alternatives).

    What alternative solutions did you explore? (Optional)

    Reconcile submitsTo on the write side instead. In updateApprovalWorkflow, the workflow-change payload only ships the diff (employees: JSON.stringify(Object.values(updatedEmployees))) and convertApprovalWorkflowToPolicyEmployees only rewrites submitsTo for emails present in approvalWorkflow.members (

    const previousEmployeeList = Object.fromEntries(Object.entries(policy.employeeList ?? {}).map(([key, value]) => [key, {...value, pendingAction: null}]));
    const updatedEmployees = convertApprovalWorkflowToPolicyEmployees({
    previousEmployeeList,
    approvalWorkflow,
    type: CONST.APPROVAL_WORKFLOW.TYPE.UPDATE,
    membersToRemove,
    approversToRemove,
    defaultApprover: newDefaultApprover ?? previousDefaultApprover ?? '',
    });
    // Force the new default approver's `submitsTo` to themselves whenever the default
    // approver changes. `convertApprovalWorkflowToPolicyEmployees` only rewrites `submitsTo`
    // for emails present in `approvalWorkflow.members`, so a newly-promoted approver who
    // wasn't already a member (e.g., an agent the backend's `shareWithEmployees` just added
    // with `submitsTo = previous default approver`) keeps that stale value and shows up as
    // their own orphan submission group on the workflows page. This backstop guarantees the
    // new default approver self-submits regardless of the caller's `members` snapshot.
    if (newDefaultApprover && newDefaultApprover !== previousDefaultApprover) {
    const existing = updatedEmployees[newDefaultApprover] ?? previousEmployeeList[newDefaultApprover];
    if (existing && existing.submitsTo !== newDefaultApprover) {
    const previousPendingAction = previousEmployeeList[newDefaultApprover]?.pendingAction;
    updatedEmployees[newDefaultApprover] = {
    ...existing,
    email: newDefaultApprover,
    submitsTo: newDefaultApprover,
    pendingAction: previousPendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? previousPendingAction : CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    pendingFields: {
    ...existing.pendingFields,
    submitsTo: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    },
    };
    }
    }
    // If there are no changes to the employees list, we can exit early
    ). We could expand it to realign every member's submitsTo when the default approver changes. Rejected as the primary fix because it only prevents new desyncs — it can't repair the already-stale data that affected workspaces are hitting today, whereas the submit-side guard fixes existing and future cases.

    Treat it as a pure backend bug (reset submitsTo server-side in UpdateWorkspaceApproval). Reasonable for cleaning up OD's stored value, but it leaves ND submitting an invalid approver for any workspace whose data is already stale, and it can't be validated/permalinked from this repo. Better as a complementary cleanup than the fix for the reported submission failure.

    Make getManagerAccountEmail honor submitsTo and instead "fix" the display. Rejected — the display is already correct (User A is the valid approver). Aligning down to the stale value would make ND submit the wrong approver on purpose; the broken side is submit, not display.

  12. 70 remaining items

  13. melvin-bot commented on Aug 28, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    • Reviewer: @suneox owed $250 via NewDot
    • Assignee: @Abdulloh0109 requires payment (Needs manual offer from BZ)

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  14. suneox commented on Aug 29, 2026

    @suneox
    Contributor

    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.

      N/A: No offending PR was found as the issue cannot be reproduced consistently and the PR simply updates the fallback approver for an existing feature

    • [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: N/A

    • [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.

      N/A: It isn't easy to test for this bug

  15. Abdulloh0109 commented on Aug 31, 2026

    @Abdulloh0109
    Contributor
  16. melvin-bot commented on Aug 31, 2026

    @melvin-bot

    @mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  17. mallenexpensify commented on Sep 1, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @Abdulloh0109 paid $250 via Upwork
    Contributor+: @suneox due $250 via NewDot

    @Abdulloh0109 can you please accept the job below? Please reply here and tag me once you have.
    If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
    https://www.upwork.com/jobs/~022094785079447017772

  18. Abdulloh0109 commented on Sep 3, 2026

    @Abdulloh0109
    Contributor

    The payment was significantly delayed.

  19. mallenexpensify commented on Sep 3, 2026

    @mallenexpensify
    Contributor

    @Abdulloh0109 can you please accept the job below? Please reply here and tag me once you have.

    @Abdulloh0109 we manage payments via GH, I don't know if/when you accepted the job in Upwork if you don't tag me on a post in a GH comment.

    @Abdulloh0109 paid, summary updated above. Thx.

  20. garrettmknight commented on Sep 22, 2026

    @garrettmknight
    Contributor

    $250 approved for @suneox

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 contributorNeeds ReproductionReproducible steps needed

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions