Skip to content

fix: KYC flow doesn't trigger after adding bank account when paying another user#92154

Merged
chuckdries merged 25 commits into
Expensify:mainfrom
samranahm:91873/trigger-kyc-after-adding-account
Jun 25, 2026
Merged

fix: KYC flow doesn't trigger after adding bank account when paying another user#92154
chuckdries merged 25 commits into
Expensify:mainfrom
samranahm:91873/trigger-kyc-after-adding-account

Conversation

@samranahm

@samranahm samranahm commented May 31, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

When paying another user with a personal bank account, the KYC flow wasn't triggering after adding the account. The cause was AccountFlowEntryPoint calling clearPersonalBankAccount() on mount, which wiped the onSuccessFallbackRoute that the pay flow sets before this screen and that AddPersonalBankAccountPage reads after it, so the app could no longer continue into KYC.

To fix this we:

  1. Thread onSuccessFallbackRoute through the KYC flow, pay/search/settlement flows pass personalBankAccountOnSuccessFallbackRoute into triggerKYCFlow, and Wallet uses getPersonalBankAccountOnSuccessFallbackRoute, both store the route in PERSONAL_BANK_ACCOUNT via openPersonalBankAccountSetupView when the user selects "Personal bank account".

  2. Preserve the route on entry, AccountFlowEntryPoint still clears stale PERSONAL_BANK_ACCOUNT state on mount (for deep links and any edge case leftover data), but passes onSuccessFallbackRoute into clearPersonalBankAccount so the KYC continuation route survives.

  3. Reset cleanly between flows, openPersonalBankAccountSetupView now use Onyx.set instead of merge, so each new flow starts with only the fields explicitly passed.

Fixed Issues

$ #91873
PROPOSAL: #91873 (comment)

Tests

Precondition:

  • The user does not have a personal bank account connected.

Test 01

  1. Start a 1:1 conversation with another user.
  2. Press the + button and select Pay [User].
  3. On the amount screen, tap the currency selector and choose USD, then enter any amount and continue.
  4. Verify that the payment method dropdown displays "Pay with personal account".
  5. Press "Pay with personal account" and verify that the bank account connection flow starts.
  6. Add a bank account using either Plaid or manual entry, then press Continue on the "Bank account added" page.
  7. Verify the KYC verification flow is triggered (confirm additional details to process the payment)

Test 02

  1. Go to Settings > Wallet and press "Add bank account".
  2. Select "Get reimbursed", then choose United States as the country.
  3. Enter the bank account details (Plaid or manual entry) and press Continue.
  4. On the "Let's double-check..." page, press Confirm and verify the bank account is added (the "Bank account added" page is shown).
  5. Press Continue and verify that the user is returned to Add bank account entry point (Streamline payments) page, the KYC flow is not triggered and the additional details page does not open.
  • Verify that no errors appear in the JS console

Offline tests

N/A – Bank account setup can only be run while online.

QA Steps

Same as test

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • 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 by adding it to src/languages/* files and using the translation method
    • 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. 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • 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 (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • 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.Native.mp4
Android: mWeb Chrome
Android.mWeb.Chrome.mp4
iOS: Native
IOS.Native.mp4
iOS: mWeb Safari
IOS.mWeb.Safari.mp4
MacOS: Chrome / Safari
macOS.Chrome.mp4

Copilot AI review requested due to automatic review settings May 31, 2026 17:13
@samranahm samranahm requested review from a team as code owners May 31, 2026 17:13
@melvin-bot melvin-bot Bot requested review from Eskalifer1 and flaviadefaria May 31, 2026 17:13
@melvin-bot

melvin-bot Bot commented May 31, 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]

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adjusts the personal bank account clearing logic so that, when entering the international deposit account flow, routing-related data is preserved while transient UI/error state is reset.

Changes:

  • Added a shouldPreserveRoutingData parameter to clearPersonalBankAccount that, when true, only clears loading/error/success flags instead of wiping the entire Onyx key.
  • Updated AccountFlowEntryPoint to call clearPersonalBankAccount(true) to retain routing data on mount.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/libs/actions/BankAccounts.ts Adds optional preserve flag to selectively merge-clear transient state instead of nulling the whole bank account key.
src/pages/settings/Wallet/InternationalDepositAccount/subPages/AccountFlowEntryPoint.tsx Passes true to preserve routing data when clearing on entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/libs/actions/BankAccounts.ts Outdated
Comment thread src/libs/actions/BankAccounts.ts Outdated

@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: d1e59aa03c

ℹ️ 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".

@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/libs/PaymentUtils.ts 81.73% <100.00%> (-0.16%) ⬇️
src/libs/actions/Search.ts 39.15% <0.00%> (+0.07%) ⬆️
src/pages/settings/Wallet/WalletPage/index.tsx 0.00% <0.00%> (ø)
src/components/SettlementButton/index.tsx 82.06% <0.00%> (-0.32%) ⬇️
src/libs/actions/BankAccounts.ts 22.33% <84.61%> (+11.06%) ⬆️
...lDepositAccount/subPages/AccountFlowEntryPoint.tsx 0.00% <0.00%> (ø)
src/components/KYCWall/BaseKYCWall.tsx 27.48% <5.88%> (-0.91%) ⬇️
... and 14 files with indirect coverage changes

Comment thread src/libs/actions/BankAccounts.ts Outdated
Comment on lines +294 to +300
function clearPersonalBankAccount(shouldPreserveRoutingData = false) {
/**
* Clears personal bank account state. Pass `shouldPreserveAccountData=true` to only clear UI/error
* fields while keeping routing and context fields intact.
*/
function clearPersonalBankAccount(shouldPreserveAccountData = false) {
clearPlaid();
if (shouldPreserveRoutingData) {
if (shouldPreserveAccountData) {

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 don't think we should do it this way, because we currently have cleanup logic throughout the entire project, so I think we should keep it.

I think that when we added the cleanup logic, we simply forgot that onSuccessFallbackRoute shouldn’t be cleaned up, so I think we should just fix that. If we leave it as it is now, we’ll definitely get regressions and incorrect behavior.

I think it should look something like this:

function clearPersonalBankAccount(preservedData?: Partial<PersonalBankAccount>) {
    clearPlaid();
    Onyx.set(ONYXKEYS.PERSONAL_BANK_ACCOUNT, preservedData ?? null);
    Onyx.set(ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM_DRAFT, null);
    clearPersonalBankAccountSetupType();
}

And pass it like this:

   useEffect(() => {
        clearPersonalBankAccount(personalBankAccount?.onSuccessFallbackRoute ? {onSuccessFallbackRoute: personalBankAccount.onSuccessFallbackRoute} : undefined);
    }, []);

What do you think about that?

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.

Agreed, that's much cleaner approach. Updated clearPersonalBankAccount to take preservedData?: Partial<PersonalBankAccount> with Onyx.set(preservedData ?? null), and the entry point now passes only onSuccessFallbackRoute. All other call sites stay as a full reset, so no behavior change of any kind there.

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

Please fill out the Explanation of Change section

Let's also add some information to the Offline tests section, specifically “N/A” and the reason why there are no offline tests here

@Eskalifer1

Copy link
Copy Markdown
Contributor

I also think we should update the preconditions, specifically to specify that both users must have currency in USD:
Both users in USD currency default

Comment thread src/libs/actions/BankAccounts.ts
Co-authored-by: Eskalifer1 <artemkryt1800@gmail.com>
@samranahm

Copy link
Copy Markdown
Contributor Author

Thanks @Eskalifer1 for taking a look, I'm looking into this and will update the PR shortly.

@Eskalifer1

Copy link
Copy Markdown
Contributor

Sure! Let me know when this PR will be ready for next round of reviews!

@Eskalifer1

Copy link
Copy Markdown
Contributor

@codex review

@Eskalifer1

Eskalifer1 commented Jun 3, 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 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 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 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 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
91873-android-native.mov
Android: mWeb Chrome
91873-android-web.mov
iOS: HybridApp
91873-ios-native.mov
iOS: mWeb Safari
91873-ios-web.mov
MacOS: Chrome / Safari
91873-web.mov

@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: 249dba04e1

ℹ️ 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".

useEffect(() => {
clearPersonalBankAccount();
}, []);
clearPersonalBankAccount(onSuccessFallbackRoute ? {onSuccessFallbackRoute} : undefined);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid reusing stale KYC fallback routes

When a user starts a Pay/KYC flow that sets onSuccessFallbackRoute and then backs out from this entry point, nothing in the entry-point back path clears PERSONAL_BANK_ACCOUNT; with this change, the stale fallback route is preserved instead of being wiped. If the same user later starts a normal Wallet > Add bank account flow, this line preserves that old route again, and AddPersonalBankAccountPage.exitFlow(true) will call continueSetup(...) instead of just returning to Wallet after success. Please only preserve the fallback for the active KYC-launched flow or clear it when the add-bank flow is abandoned.

Useful? React with 👍 / 👎.

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.

This is valid concern. I think we should find a solution to this. Although it's unlikely, it's still possible

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.

Updated the logic to handle this edge case.

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.

Hi @samranahm, I don't really think that's the approach we want to take. After all, it makes more sense to clear the previous data on entry (which is much more stable) rather than on exit—plus, that's the logic that's been working for a very long time.

Can you check how onSuccessFallbackRoute was being cleared before this useEffect was added? Maybe that will give us a little more information.

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.

@MelvinBot How can this be fixed using this approach:

const [personalBankAccount, personalBankAccountResult] = useOnyx(ONYXKEYS.PERSONAL_BANK_ACCOUNT);

const isLoadingPersonalBankAccount = isLoadingOnyxValue(personalBankAccountResult)

useEffect(() => {
    if (isLoadingPersonalBankAccount) {
        return;
    }
    clearPersonalBankAccount(onSuccessFallbackRoute ? {onSuccessFallbackRoute} : undefined);
}, [isLoadingPersonalBankAccount]);

How was onSuccessFallbackRoute cleared before this useEffect was added?

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.

Short version: onSuccessFallbackRoute has never had a dedicated clear — it's only ever wiped as a side effect of a full clearPersonalBankAccount() (which nulls the whole PERSONAL_BANK_ACCOUNT key). The entry-point mount clear was one of those full wipes, and it was the only thing protecting this screen from a stale route. So the isLoadingOnyxValue version fixes your deps concern, but on its own it does not close the stale-route hole chatgpt-codex-connector flagged in this thread — you need one more piece for that.


Q2 — How was onSuccessFallbackRoute cleared before this useEffect?

There is no route-specific clear anywhere in the codebase. The field's whole lifecycle:

So on main, entering this screen always nuked the entire object. That wipe is simultaneously (a) what kept a stale route from leaking into a later flow, and (b) what wiped the route this PR needs to keep — the bug. That's the tension: the moment you preserve the route on entry, you remove the thing that used to protect against stale routes. Note openPersonalBankAccountSetupView({}) — the generic Wallet → Add bank account entry — does not clear PERSONAL_BANK_ACCOUNT, which is precisely why chatgpt-codex-connector's scenario is reachable.

Q1 — Making the isLoadingOnyxValue approach work

It needs two pieces, not one.

Piece A — the entry-point effect (your version, corrected)
const [personalBankAccount, personalBankAccountResult] = useOnyx(ONYXKEYS.PERSONAL_BANK_ACCOUNT);
const isLoadingPersonalBankAccount = isLoadingOnyxValue(personalBankAccountResult);
const onSuccessFallbackRoute = personalBankAccount?.onSuccessFallbackRoute;

useEffect(() => {
    if (isLoadingPersonalBankAccount) {
        return;
    }
    clearPersonalBankAccount(onSuccessFallbackRoute ? {onSuccessFallbackRoute} : undefined);
    // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isLoadingPersonalBankAccount]);

with clearPersonalBankAccount(preservedData?: Partial<PersonalBankAccount>) doing Onyx.set(PERSONAL_BANK_ACCOUNT, preservedData ?? null).

Two things to get right:

  • onSuccessFallbackRoute must be derived from personalBankAccount?.onSuccessFallbackRoute (your snippet references it but doesn't declare it).
  • The isLoadingOnyxValue guard is load-bearing, not cosmetic: useOnyx returns undefined while the key hydrates. Without the guard, the first render reads undefinedclearPersonalBankAccount(undefined)Onyx.set(..., null) → the route is wiped again (the original bug). Gating on hydration guarantees you read the real route before clearing, and keeping the dep array as [isLoadingPersonalBankAccount] only means the re-seed write won't re-trigger the effect (which is also what fixes your duplicate-clean concern). ✅
Piece B — close the stale-route hole (the concern this thread is about)

Piece A alone still preserves the route on every entry, so the abandon path you and chatgpt-codex-connector discussed is still open: set route → land here → preserve → back out (nothing clears it) → later generic flow reuses the stale route.

Since you (rightly) want to keep clear-on-entry rather than move it to unmount, the targeted fix is to wipe fully when the flow is actually abandoned at this entry screen. Wrap the back handler so leaving without proceeding does a full reset:

const handleBackButtonPress = () => {
    clearPersonalBankAccount(); // full wipe — abandoning the flow must not leave a stale route
    onBackButtonPress();
};

and pass handleBackButtonPress to HeaderWithBackButton. That preserves the route while moving forward through the flow, but clears it on a real abandon — satisfying both "clear on entry is stable" and "no stale route."


To be transparent: I verified the data flow and call sites directly from the code (links above), but I did not reproduce the stale-route scenario in a running app — it's plausible and you already agreed it's valid, just flagged here as analysis rather than a confirmed repro.

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.

@samranahm I think we can try to use this approach

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.

@Eskalifer1 We have same approach in AddPersonalBankAccountPage to clear the data on unmount, this make sure we clear everything when flow finish to make sure each new flow start fresh.

useEffect(() => clearPersonalBankAccount, []);

This is already established approach through out the codebase.

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.

It's already 1AM for me, so i will take a closer look tomorrow

@samranahm

Copy link
Copy Markdown
Contributor Author

@Eskalifer1 Preserving onSuccessFallbackRoute approach worked, but it indeed leaves an old route saved after the user leaves without finishing. This is most unlikely to happen, but it can still cause a regression, and we should consider it an edge case.

We actually merge onSuccessFallbackRoute in setPersonalBankAccountContinueKYCOnSuccess, which we call before entering the bank account flow (pressing "Add personal bank account" in our case). Then, as soon as we land on AccountFlowEntryPoint after country selection, the whole PERSONAL_BANK_ACCOUNT was wiped to start fresh, which is what removed the route too early.

Here's what I found to be the most professional solution

Wipe PERSONAL_BANK_ACCOUNT on unmount, so we keep the onSuccessFallbackRoute that we save before entering the AccountFlowEntryPoint screen, and clear everything when the user finishes setup or goes back and restarts. This is possible because AccountFlowEntryPoint stays mounted while the user moves forward through the rest of the flow (it's under the same navigation stack), so it only unmounts and clears when the flow closes or the user goes back that is exactly what we wanted here.

@chuckdries

Copy link
Copy Markdown
Contributor

This looks pretty good to me. Sorry to be a stickler, but @Eskalifer1 would you mind running through the tests one more time on the various platforms to make sure that the latest change to the useEffect dependencies array in AccountFlowEntryPoint is safe? Thanks 🙏

@Eskalifer1

Copy link
Copy Markdown
Contributor

Hi @chuckdries Actually, we haven't really changed the logic much compared to main, but that's okay—I'll check again on Monday!

@samranahm

Copy link
Copy Markdown
Contributor Author

removing onSuccessFallbackRoute from deps.

@shawnborton

Copy link
Copy Markdown
Contributor

@Eskalifer1 good eye! Yes, let's please fix that spacing/padding issue.

@Eskalifer1

Copy link
Copy Markdown
Contributor

Hi @chuckdries, i have tested all works good(atleast i didn;t find any issue), i think we can procced with this one!

Also desgn team decided we should fix this issue, can you create new issue for that pls!

I think i can work with Melvin on this one to make sure all works well and i didn't miss something!

Or we can open for external!

@samranahm

samranahm commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

When user selects only one account in Plaid, we still show the “Choose your bank account” screen with a single predetermined option in radio list. So user is effectively confirming the same single account they already chose in Plaid, with no real decision to make.

Should we update this to when Plaid returns exactly one eligible account, skip the “Choose your bank account” screen entirely and navigate to next screen with that account. We would keep the current behavior intact when two or more accounts are returned, since that is where the user actually needs to choose.

Screenshot 2026-06-23 at 3 08 14 AM

cc: @chuckdries @shawnborton

@Eskalifer1

Copy link
Copy Markdown
Contributor

When user selects only one account in Plaid, we still show the “Choose your bank account” screen with a single predetermined option in radio list. So user is effectively confirming the same single account they already chose in Plaid, with no real decision to make.

Should we update this to when Plaid returns exactly one eligible account, skip the “Choose your bank account” screen entirely and navigate to next screen with that account. We would keep the current behavior intact when two or more accounts are returned, since that is where the user actually needs to choose.

I don't think this is related to this issue and seems like change to logic that is working now. But it's just IMO

@shawnborton

Copy link
Copy Markdown
Contributor

I don't mind that idea, but I also don't think we need to make any changes to the flow - the extra account name confirmation isn't necessarily a bad thing.

@chuckdries

Copy link
Copy Markdown
Contributor

I don't think we should skip the choose account screen here, would be out of scope for this fix.

@chuckdries

Copy link
Copy Markdown
Contributor

Ok, just running through the test steps one last time. Test 1 passes, but for test 2, I noticed that the user is returned to the "Streamline payments" screen, even though we can see underneath that the bank account was successfully added. @samranahm @Eskalifer1 can either of you confirm whether this is a regression in this PR?

kyc.PR.test.mp4

@Eskalifer1

Copy link
Copy Markdown
Contributor

Ok, just running through the test steps one last time. Test 1 passes, but for test 2, I noticed that the user is returned to the "Streamline payments" screen, even though we can see underneath that the bank account was successfully added. @samranahm @Eskalifer1 can either of you confirm whether this is a regression in this PR?

kyc.PR.test.mp4

I see there is the same bahaviour on stage, so it's not regression. Let's update Test case @samranahm and resolve conflict

@samranahm

Copy link
Copy Markdown
Contributor Author

Agree with @Eskalifer1, we're not changing this behaviour in our PR. Updated the test steps.

…fter-adding-account

# Conflicts:
#	src/components/KYCWall/BaseKYCWall.tsx
@samranahm

Copy link
Copy Markdown
Contributor Author

Resolved the conflict, @chuckdries all yours.

@chuckdries chuckdries merged commit 94d8365 into Expensify:main Jun 25, 2026
33 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 chuckdries 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

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/chuckdries in version: 9.4.20-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 I reviewed the changes in this PR against Expensify's help-site articles under docs/articles, and no help-site changes are required.

Why: This PR is a bug fix. It restores the KYC/identity-verification step so it correctly triggers after a user adds a personal bank account while paying another user. It threads onSuccessFallbackRoute through the KYC flow and stops AccountFlowEntryPoint from wiping that route on mount. There are no new features, UI labels, settings, or user-facing copy introduced.

The behavior this PR restores is already accurately documented:

Since these articles describe the intended flow — which is exactly what this PR makes work again — none of them are now inaccurate or incomplete. No draft docs PR has been created.

@samranahm, please confirm you agree no help-site updates are needed here. If you believe a specific article should be updated (e.g., to call out the verification step in the pay flow more explicitly), let me know and I'll create the draft PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/blimpich in version: 9.4.20-1 🚀

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.

8 participants