Skip to content

feat(card): handle unauthenticated case on money account linkage#30227

Merged
Brunonascdev merged 1 commit into
mainfrom
feat/card-money-account-linkage-auth-flow
May 15, 2026
Merged

feat(card): handle unauthenticated case on money account linkage#30227
Brunonascdev merged 1 commit into
mainfrom
feat/card-money-account-linkage-auth-flow

Conversation

@Brunonascdev
Copy link
Copy Markdown
Contributor

@Brunonascdev Brunonascdev commented May 15, 2026

Description

This branch improves the Money Account → Card linkage entry flow when the user is not authenticated with the Card backend.

Previous behaviour: Link-card CTAs from Money Account effectively sent unauthenticated users to Card home without completing auth or resuming linkage.

New behaviour:

  1. Authenticated — Unchanged: if requirements are met and the account is not already delegated, open the linkage bottom sheet (still requires moneyAccountCardToken when authenticated).
  2. Not authenticated, cardholder — Set a Redux pendingMoneyAccountCardLink flag, navigate into Card (CARD.ROOTCARD.HOMECARD.AUTHENTICATION) with showAuthPrompt: true and a postAuthRedirect payload (origin for future multi-entrypoint use). After successful login, NavigationService.navigation.goBack() pops the pushed Card.ROOT so the user returns to the tab they came from (e.g. Money) without leaving CardAuthentication on the stack or cross-navigating with a flicker. A useEffect in useMoneyAccountCardLinkage resumes: waits for cardHomeDataStatus to reach success or error before clearing the pending flag when moneyAccountCardToken is still missing (avoids clearing too early while card home data loads post-login); if delegated already, clears pending; if token is present, opens the linkage sheet and clears pending.
  3. Not authenticated, not a cardholder — Navigates to Card onboarding root with moneyAccountLinkIntent: true (Spending-limit lock for Money as spending source remains for a follow-up branch).

What changed (high level):

  1. Reduxapp/core/redux/slices/card/index.ts: pendingMoneyAccountCardLink, setPendingMoneyAccountCardLink, selectPendingMoneyAccountCardLink.
  2. HookuseMoneyAccountCardLinkage.tsx: startLinkFlow(origin), nested navigation for auth vs onboarding, resume effect with selectCardHomeDataStatus gating.
  3. Money UIMoneyHomeView.tsx: link CTA calls startLinkFlow with root-level origin { screen: Routes.MONEY.ROOT, params: { screen: Routes.MONEY.HOME } }.
  4. Card authCardAuthentication.tsx: optional route params postAuthRedirect / showAuthPrompt; on successful login when postAuthRedirect is set, goBack() on the root NavigationService instead of resetting to Card home or navigating to Money by name.

Why

  • Cardholders who start linkage from Money need auth first, then the same bottom sheet once delegation data is ready, without losing context or leaving a stale auth screen on the stack when returning to tabs.
  • moneyAccountCardToken is unavailable until post-auth card data loads; gating on cardHomeDataStatus avoids dropping the pending flag during that window.

What changed (scoped paths)

Area Files / behaviour
Redux (card slice) app/core/redux/slices/card/index.ts, app/core/redux/slices/card/index.test.ts
Linkage hook app/components/UI/Card/hooks/useMoneyAccountCardLinkage.tsx, .test.tsx
Card login app/components/UI/Card/Views/CardAuthentication/CardAuthentication.tsx, .test.tsx
Money home app/components/UI/Money/Views/MoneyHomeView/MoneyHomeView.tsx, .test.tsx

Out of scope (intentional)

  • Onboarding branch: locking Money Account as spending source on Spending Limit (moneyAccountLinkIntent wiring beyond navigation is deferred).

Changelog

CHANGELOG entry: Improved Money Account link-to-Card flow for unauthenticated cardholders (auth screen, return to origin tab without stale stack, resume linkage sheet after card data loads); added pending linkage Redux flag and onboarding navigation intent for non-cardholders.

Related issues

Fixes:

Manual testing steps

Feature: Money Account link card when not authenticated (cardholder)

  Background:
    Given Money Account is enabled and requirements for card linkage are met
    And the user is a Card cardholder but not authenticated with the Card backend

  Scenario: link card from Money home
    When the user taps the link card CTA from Money Account home
    Then they are taken to Card authentication with the auth prompt as configured
    When the user completes login successfully
    Then they return to Money Account (tab under the pushed Card stack is revealed)
    And Card authentication is not left on the stack when re-opening the Card tab
    When card home / delegation data has finished loading
    Then the linkage bottom sheet opens if the Money account is not already delegated and a card token is available

  Scenario: already delegated after login
    When the user completes login and data shows the Money account is already delegated
    Then the pending linkage flow clears without showing the sheet

  Scenario: authenticated user
    Given the user is already authenticated with Card
    When they tap link card from Money home and are not already delegated
    Then the linkage bottom sheet opens as before (no redirect to auth)

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Modifies cross-stack navigation and linkage orchestration using a new Redux pending flag; main risk is regressions in navigation stack behavior or incorrectly resuming/clearing the pending linkage state after login.

Overview
Improves the Money Account → Card linkage entry flow for unauthenticated users by introducing a pendingMoneyAccountCardLink Redux flag and a new startLinkFlow(origin) API in useMoneyAccountCardLinkage that routes users to Card auth/onboarding and resumes opening the Link Card sheet after authentication.

Updates CardAuthentication to accept an optional postAuthRedirect param and, on successful login, pop Card.ROOT via NavigationService.navigation.goBack() instead of resetting the inner Card stack, preserving the originating tab’s navigation state.

Refactors MoneyHomeView link-card CTAs to call startLinkFlow (passing the Money home origin) and expands unit tests to cover the new branching and resume behavior, including token-resolution and data-loading edge cases.

Reviewed by Cursor Bugbot for commit 34bad9c. Bugbot is set up for automated code reviews on this repo. Configure here.

@Brunonascdev Brunonascdev self-assigned this May 15, 2026
@Brunonascdev Brunonascdev requested review from a team as code owners May 15, 2026 01:33
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2 metamaskbotv2 Bot added the team-card Card Team label May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeMoney
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are focused on the Card/Money feature area:

  1. Redux slice (card/index.ts): Adds pendingMoneyAccountCardLink state, action, and selector to track pending card-money account link operations. This is a new Redux state field that persists across navigation.

  2. useMoneyAccountCardLinkage hook: Adds a new startLinkFlow function that orchestrates the full card-money account linking flow - handling authentication state, cardholder status, and navigation to appropriate screens (CardAuthentication or Card Onboarding). Also adds a useEffect that monitors the pending link state and auto-triggers the link sheet after authentication completes.

  3. CardAuthentication: Adds postAuthRedirect route parameter support so that after successful authentication, the app can navigate back to the originating screen (e.g., MoneyHomeView) instead of always resetting to card home.

  4. MoneyHomeView: Simplifies handleLinkCardPress to use the new unified startLinkFlow instead of the previous conditional navigation logic.

These changes implement a new user flow: linking a Money account to a Card from the Money home screen, with proper handling of authentication state. This is squarely within the SmokeMoney test scope which covers Card home screen, Add Funds flows, and card analytics. No other feature areas (Confirmations, Swaps, Accounts, etc.) are affected by these changes.

Performance Test Selection:
The changes are focused on navigation flow logic and Redux state management for the card-money account linking feature. There are no changes to rendering performance, list components, data loading patterns, or app initialization that would warrant performance testing.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@Brunonascdev Brunonascdev added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit ef84315 May 15, 2026
178 of 180 checks passed
@Brunonascdev Brunonascdev deleted the feat/card-money-account-linkage-auth-flow branch May 15, 2026 14:07
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-L team-card Card Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants