Skip to content

[Payment due @Eskalifer1] fix: don't show DEW approve error next step for auto-approval failures - #96198

Merged
NicolasBonet merged 4 commits into
Expensify:mainfrom
abzokhattab:abzokhattab/fix-dew-auto-approve-next-step
Jul 31, 2026
Merged

NicolasBonet merged 4 commits into
Expensify:mainfrom
abzokhattab:abzokhattab/fix-dew-auto-approve-next-step

Conversation

@abzokhattab

@abzokhattab abzokhattab commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Restores the automaticAction check for DEW approve failure next steps. The check was added during #79165's development in commit b59668317fb , but a later commit in the same PR (a9b205c73aa) accidentally dropped the condition while scoping the error to the current approver, so the intended behavior never shipped to main. When DEW blocks auto-approval (DEW_APPROVE_FAILED with automaticAction: true), the report should keep the normal workflow next step (e.g. "Waiting for A to approve the report"). The red error next step should only appear for manual approval failures (automaticAction: false) when the current user is the approver.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/652010
PROPOSAL:

Tests

Prerequisites:

  • Use a Control workspace with DEW enabled
  • Ask an internal employee to enable DEW processor GENERIC_CATEGORY_THRESHOLD_AUTO_APPROVAL on the workspace (by default this DEW blocks all auto-approval)
  • Enable "Auto-approve compliant reports" on the workspace (Workflows / Rules) and set audit rate to 0% so the report would normally auto-approve without DEW
  • Add at least one approver member (A) to the workspace

Test 1: Auto-approve blocked by DEW (customer regression)

  1. Create and submit an expense report that would normally be auto-approved (compliant report under the auto-approve limit)
  2. Verify DEW blocks auto-approval and report actions show:
    • submitted
    • Concierge: report routed to A due to custom approval workflow
    • Concierge: failed to approve via workspace rules because...
  3. Sign in as approver A and open the report
  4. Verify next step is "Waiting for you to approve" / "Waiting for A to approve the report"
  5. Verify next step is not "This report can't be approved. Please review the comments to resolve"
  6. Verify the Approve button is still available so A can manually approve
  • Verify that no errors appear in the JS console

Offline tests

Same as tests

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 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 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.
  • 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 image
Android: mWeb Chrome image
iOS: Native Screenshot 2026-07-28 at 16 16 38
iOS: mWeb Safari Screenshot 2026-07-28 at 16 17 34
MacOS: Chrome / Safari

Before

Screen.Recording.2026-07-17.at.01.54.11.mov

After

Screen.Recording.2026-07-17.at.01.54.20.mov

Restore the automaticAction check removed in Expensify#79165 so auto-approval
blocks keep the normal workflow next step while manual approval failures
still show the error banner to the current approver.
@abzokhattab
abzokhattab requested review from a team as code owners July 15, 2026 16:18
@melvin-bot
melvin-bot Bot requested review from Eskalifer1 and removed request for a team July 15, 2026 16:18
@melvin-bot

melvin-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

@Eskalifer1 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 joekaufmanexpensify and removed request for a team July 15, 2026 16:18
@Eskalifer1

Copy link
Copy Markdown
Contributor

Hi! I will review it in a couple of hours 😃

@abzokhattab

Copy link
Copy Markdown
Contributor Author

its not ready for review yet sorry ... i am not sure if c+ is needed .. need to confirm with @sakluger

@abzokhattab
abzokhattab marked this pull request as draft July 15, 2026 21:54
@abzokhattab
abzokhattab marked this pull request as ready for review July 16, 2026 23:56
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/libs/NextStepUtils.ts 77.36% <100.00%> (+5.54%) ⬆️
src/hooks/useOptimisticNextStep.ts 0.00% <0.00%> (ø)
... and 9 files with indirect coverage changes

Extract shouldShowDynamicExternalWorkflowApproveErrorNextStep so we can
unit test that auto-approve failures keep the normal next step while
manual failures still show the error banner for the current approver.

@joekaufmanexpensify joekaufmanexpensify 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.

Good for product

@abzokhattab

Copy link
Copy Markdown
Contributor Author

This is ready for review @sakluger .. Let us know if a C+ review would be needed

@sakluger

Copy link
Copy Markdown
Contributor

@abzokhattab probably good to have a C+ review it. I see @Eskalifer1 is assigned to review it, that should be sufficient.

@Eskalifer1

Eskalifer1 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Hi @sakluger, could you please add me to the workspace with DEW enabled(as stated in preconditions), so i could all test?

My account is artemkryt1800+test2@gmail.com

Prerequisites:

  • Use a Control workspace with DEW enabled
  • Ask an internal employee to enable DEW processor GENERIC_CATEGORY_THRESHOLD_AUTO_APPROVAL on the workspace (by default this DEW blocks all auto-approval)
  • Enable "Auto-approve compliant reports" on the workspace (Workflows / Rules) and set audit rate to 0% so the report would normally auto-approve without DEW

@Eskalifer1

Copy link
Copy Markdown
Contributor

Hi @sakluger gentle bump on comment above, thank you!

@sakluger

Copy link
Copy Markdown
Contributor

@Eskalifer1 Sorry for the delay! I've added you to my workspace Tommy's Tasty Tacos (E72BDF3A9DBE334A) as an admin, and applied the GENERIC_CATEGORY_THRESHOLD_AUTO_APPROVAL DEW. I set the auto-approval threshold to $1000 and set the random audit % to 0%.

@Eskalifer1

Copy link
Copy Markdown
Contributor

Hi @abzokhattab, could you please pin-point where it was accidentally removed in #79165?

I can't find that, If this has never been implemented, then the Explanation of Change should be corrected.

@Eskalifer1

Copy link
Copy Markdown
Contributor

On more q: Do you plan to record videos for all other platforms?

@Eskalifer1

Eskalifer1 commented Jul 28, 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
96198-android-native.mov
Android: mWeb Chrome
96198-android-web.mov
iOS: HybridApp
96198-ios-native.mov
iOS: mWeb Safari
96198-ios-web.mov
MacOS: Chrome / Safari
96198-web.mov

@Eskalifer1

Copy link
Copy Markdown
Contributor

Hi @abzokhattab i have left 2 comment, let me know when you give an answer, thank you!

@abzokhattab

Copy link
Copy Markdown
Contributor Author

done @Eskalifer1

@Eskalifer1 Eskalifer1 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.

LGTM!

@melvin-bot melvin-bot Bot changed the title fix: don't show DEW approve error next step for auto-approval failures [Payment due @Eskalifer1] fix: don't show DEW approve error next step for auto-approval failures Jul 28, 2026
@melvin-bot

melvin-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🎯 @Eskalifer1, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/652010.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

@abzokhattab

Copy link
Copy Markdown
Contributor Author

@sakluger no internal engineer was added to review this. How can i trigger that

@abzokhattab

Copy link
Copy Markdown
Contributor Author

@Eskalifer1 can u approve again maybe this time a backend engineer will be assigned?

@Eskalifer1 Eskalifer1 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.

LGTM!

@NicolasBonet
NicolasBonet merged commit 1373e17 into Expensify:main Jul 31, 2026
40 of 41 checks passed
@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.

@github-actions

Copy link
Copy Markdown
Contributor

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

@sakluger
sakluger requested a review from a team July 31, 2026 16:42
@melvin-bot
melvin-bot Bot requested a review from situchan July 31, 2026 16:42
@melvin-bot

melvin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

@situchan 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 removed the request for review from a team July 31, 2026 16:42
@situchan

Copy link
Copy Markdown
Contributor

@MelvinBot can you prevent assigning reviewers on merged PRs?

@MelvinBot

Copy link
Copy Markdown
Contributor

Good call — assigning a reviewer and requesting the checklist on an already-merged PR is just noise.

This isn't controlled by any workflow in this repo (the reviewer-assignment + checklist request comes from the Melvin service), so it can't be fixed with an App PR. I filed a tracking issue to add a guard that skips reviewer assignment when the PR is already merged: https://github.com/Expensify/Expensify/issues/666894

@OSBotify

OSBotify commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.4.48-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no docs changes required

I reviewed the changes in this PR against the help site files under docs/articles, and no help site updates are needed.

Why: This is an internal bug fix that restores the automaticAction check when computing the report next step chip. It corrects a regression where the red "This report can't be approved. Please review the comments to resolve." next step was shown for auto-approval failures blocked by a Dynamic External Workflow (DEW), instead of keeping the normal "Waiting for … to approve" next step. The fix is limited to next-step display logic in NextStepUtils.ts and useOptimisticNextStep.ts (plus tests).

It does not add, rename, or change any user-facing feature, workspace setting, tab, or button. The auto-approval feature itself is documented in Add-Approvals.md (the Auto-approve compliant reports setting), but that configuration flow and its labels are unchanged by this PR. The specific next-step message wording is computed UI that isn't described in any help article, so there is nothing to update.

No draft docs PR was created.

@abzokhattab, please confirm you agree no help site changes are needed here. If you believe a documented behavior did change, let me know and I'll draft the help site PR.

@m-natarajan

m-natarajan commented Aug 3, 2026

Copy link
Copy Markdown

@NicolasBonet @abzokhattab @Eskalifer1 Blocked from validating this PR because of this requirement Ask an internal employee to enable DEW processor GENERIC_CATEGORY_THRESHOLD_AUTO_APPROVAL on the workspace (by default this DEW blocks all auto-approval)

@sakluger

sakluger commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@m-natarajan let me know if you need me to enable the DEW on one of your test workspaces.

@m-natarajan

Copy link
Copy Markdown

@sakluger We have the following DEW enabled accounts

  1. applausetester+ndk80@applause.expensifail.com
  2. applausetester+rg_46@applause.expensifail.com
    Not sure these accounts meet the procondition enable DEW processor GENERIC_CATEGORY_THRESHOLD_AUTO_APPROVAL on the workspace (by default this DEW blocks all auto-approval)

@NicolasBonet

NicolasBonet commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@sakluger We have the following DEW enabled accounts

  1. applausetester+ndk80@applause.expensifail.com
  2. applausetester+rg_46@applause.expensifail.com
    Not sure these accounts meet the procondition enable DEW processor GENERIC_CATEGORY_THRESHOLD_AUTO_APPROVAL on the workspace (by default this DEW blocks all auto-approval)

Added for policy F7CEFC312A481080 @m-natarajan

CleanShot 2026-08-03 at 12 10 29

@melvin-bot

melvin-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #97734

@OSBotify

OSBotify commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.4.48-3 🚀

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.

9 participants