Skip to content

Migrate card-auth modal component to a real modal - #91982

Merged
mountiny merged 39 commits into
Expensify:mainfrom
software-mansion-labs:modal-migrate/card-authentication
Oct 12, 2026
Merged

mountiny merged 39 commits into
Expensify:mainfrom
software-mansion-labs:modal-migrate/card-authentication

Conversation

@sharabai

@sharabai sharabai commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Migrates the inline CardAuthenticationModal (react-native-modal) to a real @react-navigation screen (DynamicCardAuthenticationPage), reachable via the dynamic card-authentication URL suffix. Native is intentionally inert (3DS on mobile is handled by OldDot).

Important

Behavior changes on top of the migration (improvements, not regressions):

  • "Authenticate payment" no longer detours through Add Payment Card. Pre-migration the modal needed a portal host, so Subscription pushed the Add Payment Card RHP just to host the overlay. With a real screen there is no host to justify, so re-auth opens the 3DS challenge directly on top of Subscription and closes back to Subscription.
  • 3DS screen is a root-stack route presented as a centered floating modal instead of a SETTINGS RHP sub-screen. It uses the same transparentModal screen options (centeredModalNavigator) as the other route-based centered modals, so the screen that triggered it (e.g. the Add Payment Card RHP) stays visible behind a dimmed backdrop; clicking the backdrop or pressing Esc cancels the challenge, matching the old modal's backdrop behavior.
  • The modal card's styles are copied, not shared. The geometry lives in a new styles.getCardAuthenticationModalInnerView helper whose values come from the old modal's CENTERED_UNSWIPEABLE container in ModalStyleUtils — fills the screen with a 20px inset, componentBorderRadiusLarge corners and a shadow on wide layouts; full-bleed with square corners on narrow (the inset is expressed as margins instead of the original windowWidth - 40 width computation, which drops the window-dimensions dependency). Reusing getModalStyles directly was rejected because its output is coupled to the react-native-modal contract (animationIn/animationOut, swipeDirection, safe-area flags) that a navigation route doesn't consume, and it would couple the migrated route back to the legacy modal system it's leaving — future tweaks meant for the remaining CENTERED_UNSWIPEABLE consumers would silently restyle this route. The existing getCenteredModalInnerView wasn't a fit either: it's built for fixed-width, content-hugging dialog cards (feature training, welcome modals) with a bottom-sheet shape on narrow layouts, and can't express a screen-filling card for an iframe with no intrinsic height. This mirrors how the other migrated surfaces do it (getTestToolsNavigatorInnerView, getCenteredModalInnerView are also per-surface helpers).
  • Currency defaults now resolve through usePreferredCurrency (billing-card currency → local currency → USD) everywhere — the Add Payment Card form's selector button, the currency picker, and Change Billing Currency. Previously the button and picker derived the default differently, so the button could show one currency while the picker opened pre-selected on another.
  • The add-card currency default respects the EUR_BILLING beta. usePreferredCurrency can resolve to EUR (from the user's local currency) regardless of the beta, but the currency picker only offers EUR when the beta is on. So on the add-card entry points (the Add Payment Card form default and the picker's pre-selected row) a EUR default is clamped to USD when the beta is off — keeping the default in sync with the options the user can actually pick and avoiding an unintended EUR/SCA add-card for users who can't select EUR. Change Billing Currency stays ungated, since it reflects an existing card's real currency.
  • Currency picker is scoped per flow, keeps the pick within an attempt, and resets across attempts. Saving in the Add Payment Card flow writes the draft key (ADD_PAYMENT_CARD_FORM_DRAFT, which FormProvider hydrates from) so the form no longer reverts after picking EUR/GBP and returning; the Change Billing Currency flow writes its own draft. Both the read and the write are scoped by entry point, so committing in one flow no longer bleeds into the other — previously both keys were written on every commit, which is why Change Billing Currency carried an unmount cleanup (setPaymentMethodCurrency(initialCurrency)) purely to undo the add-card half; scoping the write lets that cleanup be deleted rather than kept. clearPaymentCardFormErrorAndSubmit (run on add-card open/close) also clears the draft currency, so a fresh attempt re-defaults through usePreferredCurrency rather than hydrating a currency abandoned in an earlier attempt. That reset-on-open behaviour is long-standing but was never a recorded decision: it arrived in #43572 as a side effect of a form-wide Onyx.set whose only stated purpose was clearing stale submission errors, and no PR description or test pins it. Moving the currency to the draft key would have silently dropped it, so this PR keeps it deliberately rather than changing behaviour nobody asked to change.
    Note on provenance: the picker commits on Save rather than on row tap as of #97075, which landed on main while this PR was open and is merged in here. The per-flow scoping above applies to that Save handler; the deferred-commit interaction itself is not this PR's change.
  • Teachers Unite Add Payment Card is registered as an entry screen for the payment-card-currency dynamic route, so the currency picker no longer 404s from that flow.
  • "Authenticate payment" is gated while a request is in flight. Rapid clicks previously fired one VerifySetupIntent request each (up to ~9 back-to-back). The button's isLoading is now bound to a new optimistic Onyx flag (SUBSCRIPTION_VERIFY_SETUP_INTENT_PENDING), set in the request's optimisticData and cleared in successData/failureData — so the button shows a spinner and additional clicks are no-ops until the response lands.
  • The 3DS link is now scoped to the screen that triggered it. verify3dsSubscription is a single global Onyx key, so previously clicking Authenticate payment and then opening Change payment card would let the in-flight auth link open the challenge iframe on top of the Add Payment Card page — unexpected, since by then the user means to start a fresh add-card flow. The producing request now records its own route.name in verify3dsSubscriptionSource via its successData, so the source lands in the same Onyx flush as that response's link and stays tied to it (overlapping requests can't make the source point at a different attempt than the link). The navigation hook only reacts to a link when the focused screen matches that source — so a link can no longer be consumed by an unrelated screen the user has since navigated to.
  • Repeat 3DS attempts always reopen, even when the backend returns a byte-identical SCA link. The navigation hook fires only on a change to verify3dsSubscription, and the backend hands back the same link on retries. Rather than clearing the link from multiple consumer spots (on close, on orphan), every link-producing action now clears it first at a single seam (prepareCardAuthentication, gated by the presence of a source) before issuing its request — so the response, new or identical, always lands as a '' → URL change. Stale links from an abandoned attempt or a reload are inert at mount (the mount-time run is skipped) and overwritten by the next attempt.

Fixed Issues

$ #90477

Tests

🔴 The 3DS iframe only appears for GBP or EUR — always pick GBP/EUR in the currency selector and press Save. The selector commits on Save, not on row tap, so leaving via the back caret discards the pick. Use Stripe test card 4000 0000 0000 3220 (3DS Required) on a staging account in Stripe test mode. The challenge iframe has its own Complete authentication / Fail authentication buttons.

Setup for Flow A / D: the Account → Subscription menu item only shows if you own a paid workspace. If you don't see it, create a workspace and switch its plan to Control.

Flow A — Subscription add card

  1. Go to Account → Subscription. If no card on file, click Add payment card; otherwise click the card's ⋮ menu → Change payment card.
  2. Fill the form, set currency to GBP or EUR, submit. Verify the challenge opens as a centered floating card (20px inset, rounded corners) over the dimmed Add Payment Card form on wide screens, and full-screen without rounding on narrow ones.
  3. In the 3DS challenge, click Complete authentication. Verify the page auto-closes, the URL drops /card-authentication, and the card is added.
  4. Repeat the flow but click Fail authentication. Verify the page stays open and the header back returns you to the Add Payment Card form.
  5. Cross-flow scoping check. On the Add Payment Card form open the Currency row, pick GBP, press Save, then back out of the form. Now open the card's ⋮ menu → Change payment currency and verify it shows the card's actual currency, not GBP. Do the reverse too: change the currency to GBP there, back out, then open Change payment card and verify the form defaults through usePreferredCurrency instead of showing GBP.

Flow B — Teachers Unite add card (requires an account with no billing card on file — easiest is a fresh test account)

  1. Go to Account → Save the World and toggle Enable Personal Karma ON.
  2. Fill the add-card form, GBP or EUR, submit.
  3. Complete the 3DS challenge and verify the page auto-closes back to Save the World.
  4. While on the form, open the Currency row, pick EUR, press Save, and verify the form still shows EUR (regression check for the draft-key fix). Reopen the row and verify EUR is pre-selected with Save disabled — the persisted pick and the selection now agree, so there is nothing to commit.

Flow C — Workspace owner change (needs two accounts: Owner A and Admin B)

  1. As Owner A, create a workspace and invite B as Admin.
  2. Log in as B. Open Workspace → Members → A (the owner) and press Transfer owner.
  3. When the Enter your payment card to transfer ownership form appears, enter a GBP/EUR card, accept terms, submit.
  4. Complete the 3DS challenge. Verify ownership actually transfers (not just a card add), the /card-authentication suffix is removed, and exiting the owner-change flow returns to the screen it was opened from without a backTo query parameter.

🔧 If B is on an active free trial, RequestWorkspaceOwnerChange returns success immediately and the card/3DS step is skipped. To reach the card form, expire the trial first by setting the trial NVP to a past date (in testing this was enough for the owner-change call to come back requiring a billing card). Temporary shim to drop into WorkspaceOwnerChangeWrapperPage:

// import Onyx from 'react-native-onyx';
useEffect(() => {
    Onyx.set(ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL, '2026-02-03 13:40:26');
}, []);

Flow D — Re-authenticate existing billing (only stageable when last billing failed with auth-required)

  1. Go to Account → Subscription and press Authenticate payment.
  2. Verify the URL goes directly to /settings/subscription/card-authentication (no Add Payment Card detour).
  3. Complete the 3DS challenge and verify billing clears and you return to Subscription.

Navigation edge cases (run on Flow A):

  1. Mid-challenge, hard-reload the tab. Verify the URL stays single-suffix (no …/card-authentication/card-authentication) and back still returns to the parent.
  2. Press header back during a challenge. Verify it returns to the parent and the page does NOT immediately reopen. Then press Authenticate payment again and verify the challenge reopens (each new attempt clears the link at the producer, so a repeat click reopens even if the backend returns the same link).
  3. Start a challenge, navigate away (or hard-reload back onto the parent URL), then return to the parent. Verify the challenge does NOT auto-reopen on its own (the mount-time run is skipped). Then trigger it again (Authenticate payment / Change payment card) and verify a fresh challenge opens normally.
  4. Mid-challenge, click the dimmed area outside the card, and in a separate attempt press Esc. Verify both cancel the challenge and return to the parent exactly like the header back caret (the parent form keeps its filled-out values).
  5. On Subscription, click Authenticate payment and then immediately open the card's ⋮ menu → Change payment card before the auth link arrives. Verify the 3DS iframe does NOT open over the Add Payment Card form — the form stays put — because the link is scoped to the screen that triggered it. Then return to Subscription and click Authenticate payment again: verify a fresh challenge opens (the next attempt clears the orphaned link at the producer, so a repeat click still registers as a change).

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 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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
the.world.mp4
change.card.with.fail.auth.payment.auth.to.change.card.page.mp4
change.ownership.mp4

@codecov

codecov Bot commented May 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.71429% with 69 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/components/CardAuthenticationView/index.tsx 0.00% 21 Missing ⚠️
...ngs/Subscription/DynamicCardAuthenticationPage.tsx 0.00% 19 Missing ⚠️
...ks/useNavigateToCardAuthenticationOnLink/index.tsx 0.00% 12 Missing ⚠️
src/libs/actions/PaymentMethods.ts 70.37% 8 Missing ⚠️
src/styles/index.ts 0.00% 4 Missing ⚠️
...components/CardAuthenticationView/index.native.tsx 0.00% 2 Missing ⚠️
.../settings/Subscription/CardSection/CardSection.tsx 66.66% 1 Missing ⚠️
.../pages/settings/Subscription/PaymentCard/index.tsx 83.33% 1 Missing ⚠️
...orkspace/members/WorkspaceOwnerPaymentCardForm.tsx 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/ONYXKEYS.ts 100.00% <ø> (ø)
src/ROUTES.ts 31.82% <ø> (ø)
src/SCREENS.ts 100.00% <ø> (ø)
src/components/AddPaymentCard/PaymentCardForm.tsx 91.66% <100.00%> (+1.34%) ⬆️
src/components/CenteredModalLayout/index.tsx 100.00% <100.00%> (ø)
src/components/DismissibleBackdrop.tsx 100.00% <100.00%> (ø)
src/hooks/useClearedAddCardDraftCurrency.ts 100.00% <100.00%> (ø)
...avigateToCardAuthenticationOnLink/index.native.tsx 100.00% <100.00%> (ø)
src/libs/ExportOnyxState/masking.ts 80.95% <ø> (ø)
src/libs/Navigation/AppNavigator/AuthScreens.tsx 83.83% <100.00%> (+0.33%) ⬆️
... and 15 more

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sharabai

Copy link
Copy Markdown
Contributor Author

Update: I was testing, but found some visual bug that is not related to the issue directly, but decided to fix it since I'm already working on that component.
Other than that, it's almost ready to for review.

@sharabai

Copy link
Copy Markdown
Contributor Author

Update: found another bug/issue that could be fixed that works the same on main. Working on it

@sharabai

Copy link
Copy Markdown
Contributor Author

@codex review

@sharabai

sharabai commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor Author

There's a slight visual change in the card-auth screen.
The before look:
Screenshot 2026-06-26 at 20 17 16
Current look:
Screenshot 2026-06-26 at 20 16 28

Here're the reasons and context for this change:

  1. 3DS is a "hand off to a secure external surface, then return" step. The current implementation registers it as a root-stack fullScreen route, giving the iframe a near-viewport surface and explicit back navigation.
  2. A standard RHP would be narrower than the old centered modal, while fullScreen keeps approximately the same usable viewport size. This is a presentation choice; the navigation migration does not require it.
  3. On wide layouts, the visual delta from the old modal is the removal of its 20px inset, rounded corners, and backdrop.

@sharabai

Copy link
Copy Markdown
Contributor Author

@mountiny I tried to fix as many things that looked wrong that are currently on main, but one bug isn't fixable on FE.

Tabbing between Wallet and Subscription causes this flicker:

bug.mp4

@mountiny Is this smth that even needs to be fixed? Should I file an issue for it?
Fixing it would require help from BE and refactoring multiple places on FE that use a certain Onyx key.

A more concrete mechanism is this:
the fundList Onyx key is shared by two different backend domains
(Wallet and Subscription). Opening the Wallet causes the backend to replace
(set)
fundList with the wallet's payment‑method view — which, for an
account whose only card is the subscription billing card, is empty ({}). That
momentarily deletes the billing card the Subscription page reads, so the
empty‑state CTA renders until the Subscription's own request merges the card
back.

@sharabai
sharabai marked this pull request as ready for review June 26, 2026 18:57
@sharabai
sharabai requested review from a team as code owners June 26, 2026 18:57
@melvin-bot
melvin-bot Bot requested review from heyjennahay and parasharrajat and removed request for a team June 26, 2026 18:57
@melvin-bot

melvin-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

@parasharrajat 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 June 26, 2026 18:57
@sharabai

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: 43fec88a82

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

function WorkspaceOwnerChangeWrapperPage({route, policy, isLoadingPolicy}: WorkspaceOwnerChangeWrapperPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
useNavigateToCardAuthenticationOnLink();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we move it later where other effects are so that it is easy to spot? let's do it in each component.

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.

sure, not a problem. On one hand it's just a hook like any other, on the other hand, the hook inside uses useEffect, so moving it closer to other useEffects won't hurt.

@sharabai

Copy link
Copy Markdown
Contributor Author

@parasharrajat I've applied the changes you suggested , but also changed slightly the logic.
I'd need to do the proper testing again. For that I'd need a local backend and currently the person I was relying on is OOO and they'll be back Thursday. So till that day, I won't be able to check if the changes introduced any regressions. (They shouldn't, but it's always best to go over all the test cases).

@sharabai

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: 1041f71f6d

ℹ️ 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 on lines +381 to 383
Onyx.merge(ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM_DRAFT, {
[INPUT_IDS.CURRENCY]: currency,
});

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 Clear add-card currency draft when resetting the form

Because this setter now writes the selected currency to ADD_PAYMENT_CARD_FORM_DRAFT, the existing clearPaymentCardFormErrorAndSubmit() calls on the add-card pages no longer reset that value. If a user opens any add-card flow, selects EUR/GBP, then backs out before submitting, reopening a later add-card form will hydrate the stale draft instead of the current preferred/billing currency and can submit the card in the wrong currency/force the SCA path unexpectedly. Please clear the draft alongside the form reset or otherwise scope it to the active attempt.

Useful? React with 👍 / 👎.

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.

resolved with also clearing draft on clear cb

@sharabai

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: 6bad05980b

ℹ️ 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/PaymentMethods.ts Outdated
return;
}
clearPaymentCard3dsVerification();
setVerify3dsSubscriptionSource(source);

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 Tie the 3DS source to the response, not the latest attempt

When two 3DS-producing requests overlap, this single global source can be overwritten before the older response writes VERIFY_3DS_SUBSCRIPTION. For example, if a user clicks Authenticate payment, then starts Change payment card and submits an SCA card before the first response returns, the add-card call updates the source to the add-card route; a late auth-payment link will then satisfy route.name === source on the add-card screen and open the wrong challenge. The source needs to be associated with the link/request being consumed rather than stored as the latest global producer.

Useful? React with 👍 / 👎.

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.

synced source to SCA_URL

@sharabai

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: 9765b39762

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

@sharabai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 9765b39762

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

@sharabai

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: 9765b39762

ℹ️ 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 on lines +359 to +360
<InputWrapper
value={data?.currency ?? CONST.PAYMENT_CARD_CURRENCY.USD}
defaultValue={preferredCurrency}

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 Keep EUR out of defaults without the billing beta

For a user with no existing billing card whose local currency is EUR and who is not in CONST.BETAS.EUR_BILLING, usePreferredCurrency() returns EUR here and the form submits that default if the user does not change it. The selector still filters EUR out unless the beta is enabled, so this bypasses the same gating and can start the EUR/SCA add-card flow for users who cannot select EUR explicitly; clamp the default to the enabled currency options (or USD) when EUR billing is unavailable.

Useful? React with 👍 / 👎.

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.

Refactored code to gate behind a check.

@mountiny

mountiny commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for the patience, great job pushing this head! @sharabai can you please ping me in slack once you resolve

@mountiny mountiny added the InternalQA This pull request required internal QA label Oct 7, 2026

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

(Vit's agent) Requesting changes for one regression: Retry payment no longer opens the 3DS challenge for users who have an SCA billing card (GBP or EUR) and owe money.

On main

  1. The user presses Retry payment on Subscription, which calls clearOutstandingBalance().
  2. When Stripe asks for 3DS, ClearOutstandingBalance fails with 409 Stripe requires authentication. The response's onyxData still sets verify3dsSubscription to the new link and updates purchaseList.
  3. The CardSection effect sees the new link and hasFailedLastBilling, opens Add Payment Card, and the modal shows the challenge.

On this branch

  1. The same request returns the same 409, and the link lands in Onyx.
  2. useNavigateToCardAuthenticationOnLink only navigates when route.name === verify3dsSubscriptionSource. clearOutstandingBalance records no source, so the hook returns early and nothing opens.
  3. The user has no other way in. Authenticate payment only renders when amountOwed === 0 (hasCardAuthenticatedError), and these users owe money. Each retry fails and no challenge appears.

One caveat: nothing clears verify3dsSubscriptionSource. If an earlier Authenticate payment click left it set to the Subscription root screen, a retry link still opens the challenge. For these users the source is usually empty or points to another screen, so the bug shows in the common case.

Suggested fix

  1. Pass route.name from handleRetryPayment into clearOutstandingBalance(source).
  2. In clearOutstandingBalance, call prepareCardAuthentication(source) before the write, so an identical link still counts as a change.
  3. Add getVerify3dsSubscriptionSourceData(source) to its failureData, because the 3DS case comes back as a 409 and successData never runs.
  4. Add a unit test that mocks a 409 response carrying verify3dsSubscription in onyxData and checks that the source lands.

SCREENS.SETTINGS.SUBSCRIPTION.ROOT is already an entry screen for card-authentication, so the route itself needs no change.

I traced this through the client and server code and did not run it end to end. A local repro needs a GBP or EUR billing card where Stripe asks for 3DS on the charge, plus an amount owed.

@@ -214,15 +215,8 @@ function CardSection() {
clearOutstandingBalance();

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.

(Vit's agent) For SCA cards this call can come back as a 409 with a new verify3dsSubscription link. It records no verify3dsSubscriptionSource, so useNavigateToCardAuthenticationOnLink ignores that link and the challenge never opens. Passing route.name here, and recording it in the failureData of clearOutstandingBalance, brings the challenge back. The review summary has the details.

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.

Fixed in df7c993

@sharabai
sharabai requested a review from mountiny October 8, 2026 12:55
Comment thread tests/actions/PolicyMemberTest.ts Resolved
Comment thread tests/unit/PaymentMethodsTest.ts Resolved
@sharabai

sharabai commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@mountiny thanks for the review! Added Given/When/Then to the new tests.

mountiny
mountiny previously approved these changes Oct 8, 2026

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

@mountiny

mountiny commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

For QA, we will need to test with real cards on staging I think

@mountiny

mountiny commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@allgandalf we'll do one more test on native as well and update the reviewer checklist so it passes.

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

@allgandalf we'll do one more test on native as well and update the reviewer checklist so it passes.

Just realised there is nothing to test on native since we hide this on ios and android 😭 : PR lgtm, lets merge, web test worked fine

@allgandalf

allgandalf commented Oct 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 any copy / text that was added to the app 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 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 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 the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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: mWeb Safari
MacOS: Chrome / Safari

@allgandalf
allgandalf requested a review from mountiny October 12, 2026 09:55
@allgandalf

Copy link
Copy Markdown
Contributor

latest qa video

91982-qa-web.mp4

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

@allgandalf thanks for thorough testing, changes look good to me and we will see how we can qa this in staging

@mountiny
mountiny merged commit e495163 into Expensify:main Oct 12, 2026
46 of 73 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny 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/mountiny in version: 9.5.8-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR moves the 3DS screen into navigation and fixes how the currency default and the Authenticate payment button behave. No existing article sentence becomes wrong. Fix a Billing Issue still correctly says "Complete the required authentication, such as 3D Secure verification." The EUR currency behavior is behind the EUR_BILLING beta.


view run

@mountiny

Copy link
Copy Markdown
Contributor

Thorough testing done by @allgandalf

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.8-5 🚀

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

InternalQA This pull request required internal QA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants