Skip to content

Fix report submission failure when submitsTo points to a removed policy member - #98398

Merged
yuwenmemon merged 3 commits into
Expensify:mainfrom
Abdulloh0109:fix/94891-stale-submitsto-approver
Aug 20, 2026
Merged

yuwenmemon merged 3 commits into
Expensify:mainfrom
Abdulloh0109:fix/94891-stale-submitsto-approver

Conversation

@Abdulloh0109

@Abdulloh0109 Abdulloh0109 commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

An employee's submitsTo can go stale and point at someone who is no longer a member of the policy (e.g. the configured approver was removed from the workspace). The two sides of the app read that same value differently:

  • The Workflows UI validates it — convertPolicyEmployeesToApprovalWorkflows skips any member whose submitsTo doesn't resolve to a current policy member, so the member is displayed under the default approver instead.
  • The submit path did not — getManagerAccountEmail returned the raw submitsTo, which flows through getSubmitToEmail → getSubmitToAccountID → submitReport and is sent to SubmitReport as managerAccountID.

The result is exactly what the issue reports: NewDot displays the correct approver, but submitting sends an approver that is not a member of the policy, and the backend rejects it with Expensify\Error\Policy\UserNotAMember.

This PR applies the same membership guard the display path already uses to getManagerAccountEmail: submitsTo is only returned when it still resolves to an entry in policy.employeeList; otherwise it falls back to the default approver. Fixing it in the resolver covers every caller of the submit chain in one place (getManagerAccountID, getSubmitToEmail, getSubmitToAccountID, getApprovalChain).

Behavior that is intentionally unchanged:

  • Advanced workflows where submitsTo is a valid member — the guard only triggers for approvers that no longer exist.
  • Category/tag rule approvers — getSubmitToEmail resolves those before falling back to the manager.
  • Basic/optional approval modes and submit-and-close — those return earlier in the function.

A unit test was added covering the stale-submitsTo case.

Fixed Issues

$ #94891
PROPOSAL: #94891 (comment)

Tests

The stale state this PR guards against cannot be produced through the UI: removing an approver reassigns the workflow to the workspace owner ("we'll replace them in the approval workflow with … the workspace owner"), so submitsTo never ends up pointing at a non-member that way. The steps below seed that state locally and reproduce exactly what the recording shows.

  1. Run npm run web on this branch, then open https://dev.new.expensify.com:8082/ (desktop, or mWeb via remote debugging) and paste the snippet below into the browser console.
Seed snippet
await Onyx.multiSet({
    network: {isOffline: true, shouldForceOffline: true},
    isLoadingApp: false,
    isLoadingReportData: false,
    nvp_onboarding: {hasCompletedGuidedSetupFlow: true},
    account: {validated: true, primaryLogin: 'employee@company.com'},
    session: {authToken: 'fakeToken', encryptedAuthToken: 'fakeToken', email: 'employee@company.com', accountID: 11111},
    personalDetailsList: {
        11111: {accountID: 11111, login: 'employee@company.com', displayName: 'Emily Employee'},
        22222: {accountID: 22222, login: 'teamlead@company.com', displayName: 'Tara Teamlead'},
        33333: {accountID: 33333, login: 'removed-approver@company.com', displayName: 'Rex Removed'},
    },
    policy_DEMO94891POLICY: {
        id: 'DEMO94891POLICY',
        name: 'Demo Workspace',
        type: 'corporate',
        role: 'user',
        owner: 'teamlead@company.com',
        approver: 'teamlead@company.com',
        approvalMode: 'ADVANCED',
        outputCurrency: 'USD',
        isPolicyExpenseChatEnabled: true,
        areWorkflowsEnabled: true,
        employeeList: {
            // submitsTo points at an account that is no longer a member of this policy
            'employee@company.com': {email: 'employee@company.com', role: 'user', submitsTo: 'removed-approver@company.com'},
            'teamlead@company.com': {email: 'teamlead@company.com', role: 'admin', submitsTo: ''},
        },
    },
    report_222222222222222: {
        reportID: '222222222222222',
        type: 'chat',
        chatType: 'policyExpenseChat',
        policyID: 'DEMO94891POLICY',
        ownerAccountID: 11111,
        isOwnPolicyExpenseChat: true,
        reportName: 'Demo Workspace',
        stateNum: 0,
        statusNum: 0,
        participants: {11111: {notificationPreference: 'always'}, 22222: {notificationPreference: 'always'}},
    },
    report_111111111111111: {
        reportID: '111111111111111',
        type: 'expense',
        policyID: 'DEMO94891POLICY',
        chatReportID: '222222222222222',
        ownerAccountID: 11111,
        managerID: null,
        currency: 'USD',
        total: -12550,
        unheldTotal: -12550,
        stateNum: 0,
        statusNum: 0,
        reportName: 'Expense Report #111',
        participants: {11111: {notificationPreference: 'hidden'}},
    },
    reportActions_111111111111111: {
        1: {
            reportActionID: '1',
            actionName: 'CREATED',
            created: '2026-08-12 09:00:00.000',
            actorAccountID: 11111,
            message: [{type: 'TEXT', style: 'normal', text: 'created this report'}],
            person: [{type: 'TEXT', style: 'strong', text: 'Emily Employee'}],
        },
    },
    transactions_9999999999: {
        transactionID: '9999999999',
        reportID: '111111111111111',
        amount: 12550,
        currency: 'USD',
        merchant: 'Office Supplies Co',
        created: '2026-08-12',
        comment: {comment: ''},
        reimbursable: true,
    },
});
  1. Open https://dev.new.expensify.com:8082/r/111111111111111 and reload the page.
  2. Verify the header shows Expense Report Refactor Ion so it's perrrrrfect #111 with a Draft badge and a Submit button.
  3. Click Submit.
  4. Verify the report moves to Outstanding and the next step reads "Waiting for Tara Teamlead to approve expenses" — the workspace default approver, and the same approver the Workflows page displays for that member.
  • Verify that no errors appear in the JS console

Offline tests

The snippet in the tests above forces offline mode, so what the recording shows is the optimistic result: the report moves to Outstanding and the next step names the default approver rather than the removed one. Behaviour is identical online — the same accountID is what gets sent to SubmitReport.

QA Steps

The scenario this PR fixes cannot be created through the product: removing an approver reassigns the workflow to the workspace owner, so QA cannot put a workspace into the stale state. What QA can verify is that normal approval routing is unchanged:

  1. Create a Control workspace and enable Workflows → Approvals → Advanced.
  2. Invite two members, User A and User B, and add a workflow where User B submits to User A.
  3. As User B, create an expense on that workspace and submit the report.
  4. Verify the report is submitted to User A.
  5. As the admin, remove User A from the workspace and confirm the Workflows page now lists User B under the workspace owner.
  6. As User B, submit another report and verify it goes to the workspace owner with no error.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Chrome
0ff3d116-8956-4700-9be7-d75e4b5faabb.mp4
Safari
REC-20260818222631.mp4
iOS: mWeb Safari
ios.mp4
Android: mWeb Chrome
android.mp4

@Abdulloh0109
Abdulloh0109 requested review from a team as code owners August 12, 2026 06:26
@melvin-bot
melvin-bot Bot requested a review from suneox August 12, 2026 06:26
@melvin-bot

melvin-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

@suneox Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from garrettmknight and removed request for a team August 12, 2026 06:26
@Abdulloh0109 Abdulloh0109 changed the title Fix report submission failure when submitsTo points to a removed poli… Fix report submission failure when submitsTo points to a removed policy member Aug 12, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa1cbe200c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/PolicyUtils.ts Outdated
// submitsTo can go stale and point at someone who is no longer a policy member (e.g. the configured approver was removed).
// The Workflows UI already ignores such approvers (see convertPolicyEmployeesToApprovalWorkflows), so fall back to the
// default approver to keep the submit destination consistent with what the UI displays.
if (submitsTo && policy?.employeeList?.[submitsTo]) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve HR-provided external managers

In HR advanced (manager) mode, submitsTo can intentionally name an HR-synced manager who is not in policy.employeeList; the workflow conversion path preserves that case when an HR final approver is configured (see tests/unit/WorkflowUtilsTest.ts:781-831). This membership guard now treats those valid external managers as stale and makes getSubmitToEmail/getSubmitToAccountID/getApprovalChain fall back to the workspace owner/default approver, so reports from HR-managed employees are submitted to the wrong approver instead of the manager supplied by the HR integration.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

…cy member

Only the submit path now ignores a submitsTo approver who is no longer a
policy member: getSubmitReportManagerAccountID resolves the approver via
getSubmittableApproverAccountID, which falls back to the default approver
so SubmitReport is not called with a non-member managerAccountID.

getManagerAccountEmail and getSubmitToAccountID keep returning the raw
value because they also answer "who is this report with" — for example
isAwaitingFirstLevelApproval compares it against report.managerID, so
guarding them would hide Delete on reports already sitting with a removed
approver. HR advanced (manager) mode is exempt, mirroring the HR check in
convertPolicyEmployeesToApprovalWorkflows, so an HR-synced external
manager is still honored.

Expensify#94891
@Abdulloh0109
Abdulloh0109 force-pushed the fix/94891-stale-submitsto-approver branch from fa1cbe2 to 399946a Compare August 12, 2026 07:51
@codecov

codecov Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/PolicyUtils.ts 78.10% <100.00%> (+0.42%) ⬆️
... and 226 files with indirect coverage changes

garrettmknight
garrettmknight previously approved these changes Aug 13, 2026

@garrettmknight garrettmknight left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how users are getting into this situation since both ND and Classic set the owner as the approver after another approver is removed from the WS, but it seems to have happened for that customer so an extra guard can't hurt.

Screenshot 2026-08-13 at 12.02.32 PM.png

@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

@suneox

@suneox

suneox commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

I’ll take a look at this pr tomorrow.

@suneox

suneox commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
CleanShot.2026-08-20.at.17.17.15.4.mp4
Android: mWeb Chrome
iOS: HybridApp
CleanShot.2026-08-16.at.14.14.46.2.mp4
iOS: mWeb Safari
CleanShot.2026-08-20.at.17.17.15.4.mp4
MacOS: Chrome / Safari
CleanShot.2026-08-16.at.14.14.46.2.mp4

@suneox

suneox commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

@Abdulloh0109 Your changeset differs from the originally selected proposal. If you need to update your changes based on the Codex review, please never force push as the guideline in the future
Also, your screenshot does not match your test steps, please update the screenshots/videos to align with the QA steps so it can be verified properly. Lastly, tests are missing for the other platforms.

@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

Sorry about the force push, that one's on me. Future updates will be new commits.

On the deviation: the proposal had the guard in getManagerAccountEmail, but that placement broke two things.

Codex was right about HR mode. convertPolicyEmployeesToApprovalWorkflows only ignores a non-member submitsTo when there is no HR final approver (WorkflowUtils.ts#L191), and I had dropped that condition, so HR-synced managers would have been rerouted. Same exemption is in place now.

The bigger one: guarding the shared resolver broke 4 tests in NextStepUtilsTest and ReportSecondaryActionUtilsTest, and it wasn't just fixtures. getSubmitToAccountID also answers "who is this report with" — isAwaitingFirstLevelApproval compares it against report.managerID — so a report already sitting with an approver who was removed later would lose Delete for its owner.

So the fallback now sits in getSubmittableApproverAccountID, used only by getSubmitReportManagerAccountID (callers: submitReport and Search's submit). Everything else keeps the raw value. Same result for the bug, narrower blast radius. Happy to move it back if you prefer the original placement.

You're right on the screenshots and platforms. Re-recording the flow to match the test steps and adding the missing ones.

@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

@suneox I hit a problem while re-recording the flow and could use your input.

I set up a Control workspace against the production API, switched Approvals to Advanced, and added a workflow where User B submits to User A. When I then remove User A, the app reassigns the approver instead of leaving it stale. The confirmation dialog even says so:

If you remove devspace7799+usera@gmail.com from this workspace, we'll replace them in the approval workflow with devspace7799@gmail.com, the workspace owner.

After removing, User B's submitsTo is the owner and approvalMode drops back to BASIC, so the submission succeeds with or without this PR. This matches what @garrettmknight said above about both ND and Classic reassigning the approver on removal.

So the steps in the PR can't produce the stale state on current main, which means I can't record a video that both matches them and shows the fix doing anything.

How did you get into it in July? Was it a different removal path, OldDot, or an older build? If there's no reproducible path left, I'd rather rewrite the test steps to describe a workspace that already has the stale submitsTo (the case garrettmknight described as worth guarding) and say plainly that the recording seeds that state locally. Happy to go either way, just don't want to guess.

@suneox

suneox commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

So the steps in the PR can't produce the stale state on current main, which means I can't record a video that both matches them and shows the fix doing anything.

@Abdulloh0109 You need to update the test steps to accurately reflect your screen recording. We can't provide QA steps that they are unable to verify.

@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

Updated the test steps to match the recording, and left QA steps they can actually run (the stale state can't be created through the product). Happy to mark it [No QA] instead if you prefer.

@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

Updated the test steps to match the recording, and left QA steps they can actually run (the stale state can't be created through the product). Happy to mark it [No QA] instead if you prefer.

One question on platforms: this state can only be reproduced by seeding Onyx from the browser console, which isn't available in the native apps. The change itself is a plain util in PolicyUtils with no platform-specific code. Is web (plus mWeb if you want it) enough here, or do you need native recordings too?

@suneox

suneox commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

@Abdulloh0109 The screenshot doesn't match the test steps yet, and please remove the redundant steps.

Check out this branch and run npm run web.
Open https://dev.new.expensify.com:8082/ and paste the snippet below into the browser console. It seeds a Control workspace in advanced approval mode where Emily Employee's submitsTo points at removed-approver@company.com (Rex Removed), who is not in employeeList, while Tara Teamlead is the workspace default approver.

Keep in mind that QA Steps are for QA verification, while Tests are for dev verification.

@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

@suneox All addressed:

  • Tests section trimmed — merged the setup step and dropped the unverifiable main-branch comparison step, so it now matches the recording exactly (steps 1–5).
  • Re-recorded and replaced Chrome and Safari videos to match the current Tests steps.
  • Added iOS: mWeb Safari and Android: mWeb Chrome recordings (native platforms can't reproduce this stale-submitsTo state locally, so mWeb via remote debugging was used for mobile coverage).

Ready for another look whenever you have a chance.

Comment thread src/libs/PolicyUtils.ts Outdated
Comment on lines +1890 to +1893
// `submitsTo` can go stale and name someone who is no longer a policy member (e.g. the approver was removed from the
// workspace). Only the callers that actually route a submission opt into this fallback — the raw value still answers
// "who is this report with" elsewhere (see isAwaitingFirstLevelApproval). HR advanced (manager) mode is exempt
// because it intentionally routes to an HR-synced manager who is not part of `employeeList`.

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — simplified to the suggested wording.

Comment thread src/libs/PolicyUtils.ts Outdated
Comment on lines +1909 to +1914
/**
* Returns the accountID the report can actually be submitted to. Unlike `getSubmitToAccountID`, a `submitsTo` approver
* who is no longer a policy member is replaced by the default approver, because SubmitReport rejects a non-member
* approver with UserNotAMember — the same membership check `convertPolicyEmployeesToApprovalWorkflows` already applies
* when the Workflows page decides which approver to display for that member.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abdulloh0109 Same above keep the comment accurate/simple.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this function as the comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — removed getSubmittableApproverAccountID entirely and moved the fallback flag onto getSubmitToAccountID instead (see the next comment). getSubmitReportManagerAccountID now calls getSubmitToAccountID(policy, expenseReport, submitterLogin, true).

Comment thread src/libs/PolicyUtils.ts Outdated
const approvalRules = policy?.rules?.approvalRules;
const ruleApprover = !isSubmitAndClose(policy) && approvalRules?.length ? getFirstRuleApprover(approvalRules, expenseReport, submitterLogin) : '';
const submitToAccountID = getSubmitToAccountID(policy, expenseReport, submitterLogin);
const submitToAccountID = getSubmittableApproverAccountID(policy, expenseReport, submitterLogin);

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — applied exactly this, and dropped the now-redundant getSubmittableApproverAccountID wrapper.

Drop the getSubmittableApproverAccountID wrapper and add the
membership-fallback flag directly to getSubmitToAccountID instead,
mirroring the parameter already on getSubmitToEmail. Also trims the
explanatory comments down to their essential purpose, per suneox's
review feedback on PR Expensify#98398.

@suneox suneox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current change just adds a check for employeeList existence to return the default approver. LGTM

@melvin-bot
melvin-bot Bot requested a review from yuwenmemon August 20, 2026 13:39
@yuwenmemon
yuwenmemon merged commit def3423 into Expensify:main Aug 20, 2026
41 of 44 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 yuwenmemon has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Aug 21, 2026
55 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/yuwenmemon in version: 9.4.58-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review: no changes required

I reviewed this PR against App/docs/articles and no help site updates are needed. I did not create a draft PR.

Why: This is a purely internal approval-routing fix in src/libs/PolicyUtils.ts (plus a unit test). It changes no user-facing feature, tab, setting, button, or workflow — it only makes the submit path fall back to the workspace's default approver when an employee's submitsTo points at someone who is no longer a policy member.

Crucially, the help site already documents the behavior this PR makes correct. Add-Approvals.md states, under "What happens to pending reports when I change an approver?":

You remove an approver from the workspace: if you remove a member who is an approver on pending reports, those reports are reassigned to the workspace owner.

The submit-time fallback added here aligns the actual submit routing with that documented "reassign to the workspace owner" behavior. There's no new or changed user-facing behavior to describe, so the articles remain accurate as-is.

Since no help site changes were required, there is no linked help site PR to review.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.58-4 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants