-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add DEW support for approve action #79165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
|
@bernhardoj 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] |
src/pages/Search/SearchPage.tsx
Outdated
| const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]; | ||
| return hasDynamicExternalWorkflow(policy); | ||
| }); | ||
| const dewPolicy = selectedPolicyIDList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ PERF-2 (docs)
Using .map() followed by .find() creates unnecessary intermediate objects for all items before finding the first match. This is inefficient, especially with large arrays.
Suggested fix: Use .find() directly to return early when the first DEW policy is found:
const dewPolicy = selectedPolicyIDList.find((policyID) => {
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
return hasDynamicExternalWorkflow(policy) ? policy : undefined;
});This eliminates the expensive .map() operation by combining the property check and the function call into a single iteration that stops at the first match.
There was a problem hiding this comment.
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: 3257aed800
ℹ️ 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".
| // For DEW policies, don't optimistically update stateNum, statusNum, managerID, or nextStep | ||
| // because DEW determines the actual workflow on the backend | ||
| ...(isDEWPolicy | ||
| ? {} | ||
| : { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent repeated DEW approvals while workflow pending
In approveMoneyRequest, the DEW path intentionally skips updating stateNum/statusNum/managerID (see the empty isDEWPolicy branch). Because canApproveIOU gates the Approve button only on those report fields, a DEW approval leaves the report in a still-approvable state and the Approve button stays enabled. When the DEW workflow is pending (especially online, where no optimistic action is added), users can click Approve multiple times and send duplicate approval requests. Consider disabling approval while reportMetadata.pendingExpenseAction === APPROVE or otherwise marking the report as non-approvable in the DEW path.
Useful? React with 👍 / 👎.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@abzokhattab let me know when it's ready for review |
|
There is a backend issue (#75221 (comment)) that needs to be tackled, but in the meantime, feel free to review the PR @bernhardoj |
|
The translation confirmation was requested here https://expensify.slack.com/archives/C01GTK53T8Q/p1768231105501339 |
Yes, basically any time the report couldn't be approved (manually or automatically) and the approver needs to potentially fix something on it |
|
That's both left and we're good to merge after that. |
|
@bernhardoj are you ready to final approve? |
bernhardoj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small suggestion left,
but I'm gonna approve for now, so when the suggestion is applied, @francoisl can merge this while I'm asleep 😄
|
Completed the checklist, can we rerun the actions? |
|
All yours @francoisl |
|
Looks good. One minor conflict to fix and I'll merge. Thanks! |
|
There we go @francoisl |
|
🚀 |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/francoisl in version: 9.3.11-16 🚀
|
Explanation of Change
Add Dynamic External Workflow (DEW) support for the approve action, extending the existing DEW submit functionality.
Fixed Issues
$ #75221
PROPOSAL:
Tests
Prerequisites for all tests:
- Create a new expense that contains the email address of user
Aas a description- Create a new expense that contains the email address of user
Bas a descriptionTest 1: Approve Success - Online:
Test 2: Approve Success - Offline → Online
Test 3: Approve Failed
approveTest 4: Auto-Approve Success
Test 5: Auto-Approve Failed
Offline tests
same as tests
QA Steps
Important
Sign in to one of following accounts to run QA:
If you need to use a different account, tag @francoisl in the QA slack channel for help
same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-01-12.at.15.59.46.mov
Screen.Recording.2026-01-12.at.16.00.36.mov
Android: mWeb Chrome
Screen.Recording.2026-01-12.at.15.49.01.mov
Screen.Recording.2026-01-12.at.15.49.46.mov
iOS: Native
Screen.Recording.2026-01-12.at.14.33.18.mov
Screen.Recording.2026-01-12.at.14.33.37.mov
Screen.Recording.2026-01-12.at.14.36.01.mov
iOS: mWeb Safari
Screen.Recording.2026-01-12.at.14.42.20.mov
Screen.Recording.2026-01-12.at.14.42.46.mov
MacOS: Chrome / Safari
Screen.Recording.2026-01-11.at.16.44.33.mov
Screen.Recording.2026-01-11.at.19.55.27.mov
Screen.Recording.2026-01-11.at.17.03.07.mov
Screen.Recording.2026-01-11.at.18.43.00.mov