Repository navigation
Fix empty "Upload Additional Documents" page in NonUSD owner flow - #91289
Conversation
|
@abzokhattab 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] |
|
@youssef-lr 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] |
| function BeneficialOwnerDetailsFormPages({stepNames, policyID, onFinished, backTo}: BeneficialOwnerDetailsFormPagesProps) { | ||
| const {translate} = useLocalize(); | ||
| const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); | ||
| const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); |
There was a problem hiding this comment.
❌ PERF-11 (docs)
useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT) subscribes to the entire reimbursement account object, but only achData.country is used (via getCurrencyForNonUSDBankAccount). This causes unnecessary re-renders when any unrelated field on the reimbursement account changes.
Use a selector to extract only the needed field:
const [reimbursementAccountCountry] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {
selector: (ra) => ra?.achData?.additionalData?.country,
});Then pass the extracted value directly instead of the full object, or restructure getCurrencyForNonUSDBankAccount to accept the primitive values it actually needs.
Reviewed at: 16e329e | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| const {translate} = useLocalize(); | ||
| const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); | ||
| const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); | ||
| const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); |
There was a problem hiding this comment.
❌ PERF-11 (docs)
useOnyx(ONYXKEYS.COLLECTION.POLICY + policyID) subscribes to the entire policy object, but only outputCurrency is used (via getCurrencyForNonUSDBankAccount). Policy objects are large and change frequently, causing unnecessary re-renders.
Use a selector to extract only the needed field:
const [outputCurrency] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
selector: (p) => p?.outputCurrency,
});Then pass the extracted primitive value directly instead of the full policy object.
Reviewed at: 16e329e | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
|
Valid principle (PERF-11), but the suggested path is wrong — country is at achData.country |
|
Hi @abzokhattab 👋 this PR is ready for review (all platforms tested, screenshots + unit test added). Could you take a look when you get a chance? Thanks! 🙏 |
|
@MelvinBot, review the PR and find other issues or regressions |
|
@codex review |
|
Can you please check the Ai generated comments here #91289 (comment) and here #91289 (comment) |
PR ReviewThe core logic change is correct — replacing the hardcoded One issue found: The automated reviewer flagged PERF-11 on the two new A lightweight fix that avoids refactoring const [reimbursementAccountCountry] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {
selector: (ra) => ra?.achData?.additionalData?.country,
});
const [outputCurrency] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
selector: (p) => p?.outputCurrency,
});Then inline the No other regressions found. The skip predicate correctly checks all four document flags, the |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
@abzokhattab After-fix.mp4 |
|
Well i tested it on staging and i see thats already the existing behavior on staging too trim.A8C9C6D8-26BF-447C-B237-BED6B61F6BDE.MOVCan you please check which conditions produce the bug |
Reproducible ✅This is a real, reproducible bug. It's still marked Needs Reproduction only because the literal steps in the OP no longer trigger it on Before-fix.mp4The Beneficial Owner "Upload additional documentation" page renders with no upload fields and can be skipped via Next. The page's skip logic and its render logic read the bank country from two different places, so they disagree and the empty page slips through. Why the OP's literal steps don't reproduceFor a GBP workspace the bank country is forced to The actual trigger (what the video shows)The skip predicate and the render predicate read the bank country differently, so they drift apart:
When the country lives in
→ The page is shown with only its heading + two paragraphs, no upload sections, and Next lets you skip it. Exactly the OP screenshot. Steps to reproduce
Deterministic local repro (no backend needed — paste in DevTools console, then open the link)(async () => {
const POLICY_ID = 'BUGREPRO90505GBP';
await window.Onyx.merge('policy_' + POLICY_ID, { id: POLICY_ID, name: '#90505 Repro (GBP)', type: 'corporate', role: 'admin', outputCurrency: 'GBP' });
await window.Onyx.set('reimbursementAccount', { achData: { policyID: POLICY_ID, bankAccountID: 90505, country: 'GB', currency: 'GBP', state: 'SETUP', corpay: { companyName: '#90505 Repro Ltd' } }, isLoading: false, errors: null });
await window.Onyx.set('reimbursementAccountDraft', { currency: 'GBP', ownerBeingModifiedID: 'currentUser', beneficialOwnerKeys: ['currentUser'], ownsMoreThan25Percent: true, beneficialOwner_currentUser_firstName: 'Yusuf', beneficialOwner_currentUser_lastName: 'Yuldashev', beneficialOwner_currentUser_nationality: 'GB', beneficialOwner_currentUser_ownershipPercentage: '100', beneficialOwner_currentUser_dob: '1990-01-01', beneficialOwner_currentUser_street: '123 Test St', beneficialOwner_currentUser_city: 'Guliston', beneficialOwner_currentUser_state: 'CA', beneficialOwner_currentUser_zipCode: '2222', beneficialOwner_currentUser_country: 'US' });
console.log('Seeded. Open: /bank-account/new/global/beneficial-owner-info/documents?policyID=' + POLICY_ID);
})();This reproduces the exact draft-empty / Root cause (one line)The skip rule is a narrow hardcoded Fix#91289 aligns the skip with the render: it skips the page whenever the document-status flags are all |
|
Hi @abzokhattab , could you take another look when you get a chance? Repro details + video are in the breakdown above. |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
Hi @abzokhattab @youssef-lr 👋 Friendly bump — this PR has been ready for review since May 24 and I haven't heard back since May 28. Just to re-confirm the earlier concern: the bug is real and reproducible. The reason the OP's literal steps look like "existing behavior on staging" is that for a GBP workspace the parent already skips the page for the exact country === 'GB' && nationality === 'GB' case. The actual defect is a two-sources-of-truth divergence — the skip predicate reads bank country from the form draft only, while the render predicate reads it from the draft or achData. When country lives only in achData, the two disagree and the empty "Upload Additional Documents" page slips through. Full breakdown + repro video are here. |
|
on my list |
|
Able to reproduce using #91289 (comment) Now the PDF step is hidden Untitled.movHowever, when I continue through the flow I hit a backend error on the Corpay onboarding submission. It reproduces both before and after this fix, and since the change here only toggles the visibility of the (empty) Documents page — it doesn't alter the request payload at all (no document is sent for a GB national in either case) . I don't think the error is related to this PR. but we need to check why is it happening since its blocking the user Screen.Recording.2026-06-03.at.11.07.29.mov
|
a46a251 to
95107de
Compare
|
|
Hi @abzokhattab (C+) and @youssef-lr 👋 Just a gentle follow-up on this one — the PR has been open for a few weeks now and I wanted to check in. The change is ready and tested on all platforms, with before/after evidence attached. Whenever you both have a spare moment, could we move it forward — either complete the review so we can get it merged, or, if there are concerns or it's no longer needed, let me know and we can close it out. Either way works for me; I'd just love to bring it to a clear resolution. 🙏 Thanks so much for your time and help! |
|
…05-empty-documents-page
|
@yusufdeveloper2903 can you use the new checklist please? |
|
@youssef-lr done |
|
Congrats, that's your 5th PR merged! 🎉 Do you know about the ContributorPlus role? It's an opportunity to earn more in the Expensify Open Source community. Keep up the great work - thanks! |
|
🚧 @youssef-lr has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/youssef-lr in version: 9.4.17-0 🚀
Bundle Size Analysis (Sentry): |
|
🤖 Help site review: no changes required. I reviewed this PR against the help site articles under Why: This is a purely internal UX bug fix. It changes the skip predicate in
The relevant help articles (e.g. Global Reimbursement - United Kingdom) document which documents Compliance requires for a given country/currency. This fix doesn't alter those requirements — it only prevents an empty page from rendering when no in-app document upload is needed. Since the documented behavior is unchanged, there's nothing to update on the help site, and no draft PR is needed. @yusufdeveloper2903, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR (Note: no help site PR was created because no documentation changes are required. If you believe a specific article should be updated, let me know which one and what behavior it should reflect, and I'll create the draft PR.) |
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.4.17-3 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.4.17-3 🚀
|


Explanation of Change
In the NonUSD (Corpay) bank account flow, the beneficial owner "Upload Additional Documents" sub-step could appear with no required upload fields, no requirements, and the user could skip it without entering anything.
The Documents page renders only four upload sections, each gated by
getNeededDocumentsStatusForBeneficialOwner(currency, country, nationality). For workspace currencyGBP, bank countryGB, owner nationalityGB, all four flags collapse tofalse, so the page shows only a heading and two paragraphs — an empty page.The parent (
BeneficialOwnerDetailsFormPages.tsx) was supposed to skip that page, but its skip rule was a narrow hardcodedcountry === GB && nationality === GBcheck that (1) did not match the actual render predicate, so the two could drift apart, and (2) read the bank country from the form draft only. When the country lives only inachData(e.g. after server hydration of the reimbursement account, whereCountryFullStepdoes not re-write the draft because the value already equals the default), the draft value is'', theGB && GBclause isfalse, the page is not skipped, and the empty page renders.This change derives the skip predicate from the same
getNeededDocumentsStatusForBeneficialOwnerfunction that drives the page's render, and reads country/currency through the samegetCurrencyForNonUSDBankAccounthelper already used byDocuments.tsxandConfirmation.tsx(which falls back toachData.country). The Documents sub-step is now skipped exactly when all four document flags arefalse— i.e. exactly when the page would be empty — so "page is skipped" and "page is empty" can no longer diverge. This resolves the reported GBP/UK/UK case and is future-proof for any other combination where no documents are required.Fixed Issues
$ #90505
PROPOSAL: #90505 (comment)
Tests
Offline tests
This change adds no API calls. The skip decision is computed purely from locally available Onyx data (
reimbursementAccountDraft,reimbursementAccount.achData, andpolicy.outputCurrency), so it behaves identically online and offline.QA Steps
Same as the Tests section above (run on staging).
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
After Fix:

Before Fix:

Comparison:
