Skip to content

Fix - Search bulk pay drops the selected payment method after magic code verification - #98310

Merged
mountiny merged 7 commits into
Expensify:mainfrom
software-mansion-labs:chore/bulk-action-button-payment-continue
Aug 18, 2026
Merged

mountiny merged 7 commits into
Expensify:mainfrom
software-mansion-labs:chore/bulk-action-button-payment-continue

Conversation

@jmusial

@jmusial jmusial commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Search bulk pay now stores the selected payment method via useVerifyAccountAndResume and resumes the payment automatically after magic-code verification, instead of dropping the selection when redirecting an unvalidated user to the verify-account screen.

Fixed Issues

$ #98063
PROPOSAL:

Tests

  1. Open app, log in as user whose account is not validated.
  2. Create new workspace with USD as currency.
  3. Navigate to Reports (Search) page.
  4. Create and then select several expenses/reports eligible for payment.
  5. Press green selected-items dropdown, choose bank-funded payment method (e.g. Pay with bank account).
  6. Verify that app opens verify-account (security code) screen instead of doing nothing.
  7. Enter magic code from email.
  8. Verify that after verification you return to Search page and payment flow continues automatically with method chosen in step 4 (KYC wall or payment confirmation appears).

Offline tests

QA Steps

Same as tests.

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
Screen.Recording.2026-08-11.at.16.54.07.mov
Android: mWeb Chrome
Screen.Recording.2026-08-11.at.16.46.01.mov
iOS: Native
Screen.Recording.2026-08-11.at.16.48.58.mov
iOS: mWeb Safari
Screen.Recording.2026-08-11.at.16.51.05.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-11.at.16.34.06.mov

@codecov

codecov Bot commented Aug 11, 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/actions/Search.ts 50.32% <100.00%> (-0.33%) ⬇️
src/components/Search/SearchBulkActionsButton.tsx 90.36% <40.00%> (-1.00%) ⬇️
... and 12 files with indirect coverage changes

@jmusial

jmusial commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 215cf0c823

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

Comment thread src/libs/actions/Search.ts Resolved
@jmusial
jmusial marked this pull request as ready for review August 11, 2026 14:55
@jmusial
jmusial requested review from a team as code owners August 11, 2026 14:55
@melvin-bot
melvin-bot Bot requested review from aimane-chnaif and garrettmknight and removed request for a team August 11, 2026 14:55
@melvin-bot

melvin-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

@aimane-chnaif 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 August 11, 2026 14:55
}, 0);
}, [selectedTransactions, selectedTransactionsKeys, isExpenseReportType, searchData]);

const handleBulkPaySubItemSelected = (subItem: PopoverMenuItem, triggerKYCFlow: (kycParams: ContinueActionParams) => void) =>

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.

❌ CONSISTENCY-12 (docs)

handleBulkPaySubItemSelected is named for the event slot it is wired to (onSubItemSelected) rather than the action it performs. Per STYLE.md, a callback should be named for the behavior it triggers so it stays searchable by intent and reusable across triggers; the on*/handle* naming belongs on the JSX prop, not on the function definition.

Rename the declaration to describe the action, and keep the event name only at the call site. For example:

const payBulkSelectedItem = (subItem: PopoverMenuItem, triggerKYCFlow: (kycParams: ContinueActionParams) => void) =>
    handleBulkPayItemSelected({ /* ... */ });

// call site keeps the on* naming on the prop:
onSubItemSelected={(subItem) => payBulkSelectedItem(subItem, triggerKYCFlow)}

Reviewed at: 215cf0c | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

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.

@jmusial did you want to address this one as well?

garrettmknight
garrettmknight previously approved these changes Aug 11, 2026
@aimane-chnaif

aimane-chnaif commented Aug 12, 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
Android: mWeb Chrome
iOS: HybridApp
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov

@jmusial

jmusial commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@aimane-chnaif bumpity bump

@melvin-bot
melvin-bot Bot requested a review from mountiny August 17, 2026 16:21
@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Code review — LGTM overall. The change correctly adopts the established useVerifyAccountAndResume pattern to store the selected bulk‑pay method and resume it after magic‑code validation, and it de‑duplicates the two identical inline onSubItemSelected handlers. No blocking issues found.

Why it's correct

  • The resume closure forces isUserValidated: true (Search.ts:2016), so re‑invoking handleBulkPayItemSelected skips the validation branch and proceeds to the KYC/confirm‑payment path — no infinite loop, since params still carries verifyAccountAndResume.
  • Re‑running the handler re‑evaluates the offline/locked/delegate/billing guards, so resuming stays consistent with a fresh press.
  • The (retry) => retry?.() wiring matches the existing consumers (useSelectionModePayment.ts:128, SettlementButton, MoneyReportHeaderSecondaryActions), so this is a well‑trodden pattern rather than a new one.
  • The unit test update is good — it invokes the stored retry closure and asserts confirmPayment fires, covering the resume path end‑to‑end.
Minor notes (non-blocking)
  • Stale press‑time closure: the retry captures params from press time — including isOffline, triggerKYCFlow, confirmPayment, bankAccountList. If app state changed during verification (e.g. the user dropped offline on the magic‑code screen), the resume would proceed with the stale isOffline: false path instead of the offline modal. This is the same trade‑off the existing useSelectionModePayment flow already makes (it also passes a press‑time action), and the window is tiny (resume happens right after validation on the same screen), so it's fine to keep as‑is — just noting it.
  • Codecov flags a small coverage drop on SearchBulkActionsButton.tsx:145 (the new handleBulkPaySubItemSelected wrapper). The core branching logic in Search.ts is covered by the updated unit test, so this is cosmetic.

I couldn't run an end‑to‑end verification of this flow here (it needs an unvalidated account, a USD workspace with payable reports, a bank‑funded method, and a real magic code), so I relied on code analysis plus the per‑platform videos already attached. Tests in the changed area (handleActionButtonPressTest.ts) look correct on inspection.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 630d2f4a86

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Regression scan — low risk. The only behavioral change is on the previously-broken unvalidated-user bulk-pay path; validated users are entirely unaffected, so I found no regression to existing behavior. Flagging two things to watch on the new resume path (they're new-feature edge cases, not regressions).

Why the blast radius is small

  • verifyAccountAndResume is only invoked inside the !isUserValidated branch (Search.ts:2016). For a validated user the hook's pendingAction stays null and its effect/navigationRef listener never runs, so the common pay flow is byte-for-byte the same as before.
  • isUserValidated is still the same useOnyx(ACCOUNT, {selector: isUserValidatedSelector}) — just relocated into the hook (SearchBulkActionsButton.tsx:65), so no change in loading/undefined semantics.
  • The new verifyAccountAndResume param is required, but there's only one production caller and it passes it — no dangling call site, no type break.
  • Unvalidated + "Mark as paid" (ELSEWHERE) still short-circuits to confirmPayment, and the redirect to the verify-account screen still happens (the hook calls Navigation.navigate on the same dynamic route). Both are covered by the updated unit tests.
New-path edge cases to watch (not regressions)

The resume closure () => handleBulkPayItemSelected({...params, isUserValidated: true}) captures press-time params, so the resume runs with a snapshot of state from before the user left for the magic-code screen:

  1. Stale isOffline / currentPolicy / bankAccountList / triggerKYCFlow. If any of these changed during verification (e.g. the user dropped offline on the magic-code screen), the resume would take the stale branch — e.g. skip the offline modal. Same trade-off the existing useSelectionModePayment flow already makes; window is tiny. Worth one manual check: validate while offline and confirm it doesn't try to pay online.
  2. KYC resume depends on the Search screen staying mounted. The resume re-writes pendingPaymentAdditionalDataRef.current and calls the captured triggerKYCFlow from KYCWall. If the SearchBulkActionsButton/KYCWall tree unmounts while the verify-account RHP is open, the captured ref/callback would be stale and the payment could silently fail to resume. Since verify-account is an RHP over the Search page this is normally fine — but it's the one spot I'd sanity-check on native, where screen lifecycles differ.

Testing note: I couldn't exercise the interactive bulk-pay flow end-to-end — the fresh test account has no expenses/reports, so selection mode and the green bulk-action button were never reachable. What I could confirm on the PR branch: the Search page (Expenses + Reports tabs) loads with no crash or console error, so the refactored component isn't broken on mount. A full regression pass really needs an admin account with payable reports plus the unvalidated-user + bank-account scenario from the PR's test steps.

mountiny
mountiny previously approved these changes Aug 17, 2026
}, 0);
}, [selectedTransactions, selectedTransactionsKeys, isExpenseReportType, searchData]);

const handleBulkPaySubItemSelected = (subItem: PopoverMenuItem, triggerKYCFlow: (kycParams: ContinueActionParams) => void) =>

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.

@jmusial did you want to address this one as well?

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

Thanks for addressing that

@mountiny
mountiny merged commit 484fa93 into Expensify:main Aug 18, 2026
35 of 36 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

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

@OSBotify OSBotify mentioned this pull request Aug 18, 2026
66 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.56-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

This PR is an internal bug fix — it makes Search bulk pay store the selected payment method via useVerifyAccountAndResume and resume automatically after magic-code verification, instead of dropping the selection. It restores the behavior a user already expects; it does not add or rename any feature, tab, setting, label, or button, and it changes no documented behavior.

How I checked
  • Reviewed the diff: changes are confined to src/components/Search/SearchBulkActionsButton.tsx, src/libs/actions/Search.ts, and a unit test — all app logic, no user-facing copy.
  • Searched App/docs/articles for anything documenting this flow (bulk pay from Search, "pay with bank account"/"pay elsewhere", account/magic-code verification during payment, paying multiple reports). No article describes the account-verification-then-resume step at this granularity, so there is nothing to update. Reimbursement articles (e.g. Reimbursement-Payment-Methods.md) cover payment methods generally and are unaffected by this fix.

Since no documentation is affected, I did not create a draft help site PR — there's nothing to link.

@jmusial, please confirm you agree no help site changes are needed. If you think an article should be updated (or created) to cover this flow, let me know and I'll draft the PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.56-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.

6 participants