Skip to content

Fix missing "Waiting to approve" next step on Submit workspaces#93761

Draft
abzokhattab wants to merge 2 commits into
Expensify:mainfrom
abzokhattab:fix/93685-submit-next-step-approve
Draft

Fix missing "Waiting to approve" next step on Submit workspaces#93761
abzokhattab wants to merge 2 commits into
Expensify:mainfrom
abzokhattab:fix/93685-submit-next-step-approve

Conversation

@abzokhattab

@abzokhattab abzokhattab commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

On Submit-tier workspaces (submit2026), approvals are shown as disabled in the UI, but the workspace always runs an advanced approval workflow internally (the submitter submits to a specific approver). As a result, the approvalMode synced to the client can be missing or optional.

A lot of approval-aware logic gates behavior on policy.approvalMode !== OPTIONAL, so on Submit workspaces:

  • The "Waiting for you to approve expenses" next step was never rendered before the approver approved (the reported issue).
  • The Approve action was also hidden from the approver in a couple of places that share the same assumption.

This PR fixes that:

Root cause (Next Steps):

  • PolicyUtils.getApprovalWorkflow now resolves the approval workflow to ADVANCED for Submit workspaces, regardless of the approvalMode synced from the backend. This is the central helper used by Next Steps (and other approval-aware logic), so it fixes the root cause in one place.
  • NextStepUtils — the two SUBMITTED early-returns (buildOptimisticNextStep and buildNextStepNew) no longer short-circuit to the no-approval path for Submit workspaces, so the "Waiting for … to approve" step is shown.

Same problem elsewhere (Approve action hidden):

  • ReportPrimaryActionUtils.isApproveAction and ReportPreviewActionUtils.canApprove computed isApprovalEnabled directly from policy.approvalMode, hiding the Approve action for Submit workspaces. They now treat Submit workspaces as approval-enabled (additive isSubmitPolicy(policy) guard, so non-Submit behavior is unchanged) — the approver can approve, which triggers the upgrade flow.

Note on the linked issue's "Suggested fix": the issue suggested returning OPTIONAL for Submit workspaces, which would route them to the no-approval / pay path. That contradicts the issue's stated Expected behavior ("Waiting for you to approve expenses is shown") and the Bottom-Up Submit design (the approver must approve, which triggers the upgrade flow). This PR implements the behavior that matches the Expected outcome and the design doc.

Other call sites audited — intentionally NOT changed

These also read policy.approvalMode directly but are not the same problem for Submit workspaces:

Location Why no change
ReportPrimaryActionUtils.isPrimaryPayAction Returns early for !isPaidGroupPolicy(policy) (Submit isn't paid).
ReportPreviewActionUtils.canPay Payments are disabled on Submit; returns false regardless.
actions/IOU/ReportWorkflow.ts (Pay) Submit Pay button is explicitly deferred to the Wave 3 "Upgrade on Pay" feature (existing TODO + !isPaidGroupPolicy early return).
ReportSecondaryActionUtils & SearchUIUtils CHANGE_APPROVER Submit intentionally hides the standard change-approver UI (it uses the custom "Submit to" popover).
actions/IOU/Hold.ts, SearchUIUtils approve-suggestion / segmentation Optimistic-only / non-blocking; left for a follow-up to keep this PR scoped and low-risk.

Fixed Issues

$ #93685
PROPOSAL:

Tests

  1. Enable the submit2026 beta and create a Submit workspace (or use an existing one).
  2. As a member of the Submit workspace, create an expense report with at least one expense and submit it to an approver.
  3. As the approver, open the submitted report.
  4. Verify the Next Steps banner shows "Waiting for you to approve expenses" (and shows "Waiting for <approver> to approve expenses" to the submitter / other viewers).
  5. Verify the Approve action is available to the approver (on the report header and the report preview in chat).
  6. Verify a normal Collect/Control workspace with approvals disabled (optional) still shows the no-approval next step and hides Approve (no regression).
  7. Verify a Collect/Control workspace with Basic/Advanced approvals still shows "Waiting to approve" and the Approve action.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline.
  2. Submit a report on a Submit workspace.
  3. Verify the optimistic Next Step shows "Waiting for <approver> to approve expenses".
  4. Go back online and verify the next step remains consistent.

QA Steps

Same as tests.

  • 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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized (note: no new copy added)
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. (note: no new copy added)
    • I verified proper file naming conventions were followed for any new files or renamed files.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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 (audited other getApprovalWorkflow / approvalMode consumers — see "Other call sites audited" above)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Submit (submit2026) workspaces hide approvals in the UI but always run an
advanced approval workflow internally, so the synced approvalMode can be
missing or optional on the client. That caused the SUBMITTED next step to
short-circuit to the no-approval/pay path and skip "Waiting for X to approve".

Resolve the approval workflow to ADVANCED for Submit workspaces in
getApprovalWorkflow, and stop the SUBMITTED short-circuits in NextStepUtils
from firing for Submit workspaces.
isApproveAction (primary action) and canApprove (report preview action)
gated the Approve button on `policy.approvalMode !== OPTIONAL`, which hid it
for Submit workspaces whose synced approvalMode can be optional/missing. Treat
Submit workspaces as approval-enabled so the manager can approve (which
triggers the upgrade flow), mirroring the Next Steps fix.
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.

1 participant