fix(withdraw): stop method selection bouncing back to saved accounts#2432
Conversation
Two interacting defects made 'Select new method' unusable when saved bank accounts exist: 1. Crypto click navigated to /withdraw/crypto before an amount was set. That page's no-amount guard bounces straight back to /withdraw, and since da943d6 (mobile-release, merged to dev via #2393) its unmount cleanup calls resetWithdrawFlow(), wiping selectedMethod and showAllWithdrawMethods — landing the user on the saved-accounts list instead of the amount input. Set the method in context only (same contract as bank-country selection); the withdraw page navigates to /withdraw/crypto after Continue, with the amount set. 2. The default-view effect re-ran on every user refetch (window focus, 4s pending-rail poll — each dispatches a fresh user object into redux) and unconditionally forced the saved-accounts view, yanking an open country list back after a few seconds. Latch the default view once per mount; refetches now only sync the accounts list.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesWithdraw router behavior
Estimated code review effort: 2 (Simple) | ~15 minutes Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Code-analysis diffPainscore total: 6204.89 → 6205.21 (+0.32) 🆕 New findings (7)
✅ Resolved (7)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
… add-flow default code-review round: the withdraw crypto click now goes through handleMethodSelected (one code path for 'a withdraw method was selected' — analytics payload + method shape can't drift), the add flow skips its localstorage re-read + state churn once the default view is latched, and the regression tests run against the real WithdrawFlowContextProvider instead of a hand-rolled context copy that could drift from it.
|
Deep review pass (multi-agent /code-review high) — outcomes Applied in b8e9bc4:
Investigated and NOT applied (with reasons):
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Problem
On /withdraw with saved bank accounts: tapping "Select new method" → "Crypto" landed the user back on the saved-accounts list instead of the amount input. Separately, an open country list would snap back to saved accounts on its own after a few seconds (sometimes immediately).
Fix
AddWithdrawRouterView.onCryptoClick(withdraw flow) now only sets the crypto method inWithdrawFlowContext— same contract as bank-country selection — instead of also pushing/withdraw/cryptopre-amount. The withdraw page flips to the amount step and navigates to/withdraw/cryptoafter Continue.AddWithdrawRouterViewnow latches once per mount (ref guard). User refetches still sync the saved-accounts list but no longer force the view back to saved accounts.src/components/AddWithdraw/__tests__/AddWithdrawRouterView.test.tsx— both fail on the unfixed code, pass with the fix.Risks / breaking changes
addflow shares the component; its crypto path (confirmation modal) and country navigation are untouched.QA
da943d68doriginally fixed remains fixed — reset still happens on unmount, which now only ever fires post-amount or on genuine exit).Postmortem
Regression window: landed on
dev2026-07-14 via PR #2393 (mobile-release merge). Breaking commit:da943d68d"fix(withdraw): 'Back to home' no longer bounces to the withdraw screen" (authored 2026-07-02 on the mobile-release branch).What broke (symptom 1 — Crypto click):
da943d68dmovedresetWithdrawFlow()from the success view'sonCompleteto the crypto page's unmount cleanup, to fix a real race where completing a withdrawal bounced "Back to home" to /withdraw. But/withdraw/cryptohas a render guard: noamountToWithdraw→router.push('/withdraw'). The method-selection screen had always navigated to/withdraw/cryptoon the Crypto click before an amount exists, relying on that guard bouncing back withselectedMethodstill intact in context (→ amount input step). Afterda943d68d, the bounce also unmounts the crypto page, whose new cleanup wipes the entire flow context (selectedMethod,showAllWithdrawMethods) — so the user lands on the saved-accounts list.Chain: Crypto click → set method + push
/withdraw/crypto→ no-amount guard pushes back → unmount cleanup resets flow → no method selected + showAll=false → saved accounts.What broke (symptom 2 — country list reverting on its own):
Long-latent defect, not from
da943d68d. The default-view effect inAddWithdrawRouterViewhasuserin its deps and unconditionally calledsetShowAllWithdrawMethods(false)whenever saved accounts exist. Every/users/mefetch dispatches a fresh user object into redux (userActions.setUser(payload)— no identity preservation), anduseUserQueryrefetches on window focus, on mount, and on a 4s interval while any rail is pending (useUserAutoRefresh). Each refetch re-fired the effect and yanked the open country list back to saved accounts — "after a few seconds" = the poll tick; "sometimes immediately" = an in-flight refetch resolving right after the click.Why it wasn't caught: the pre-amount
/withdraw/cryptoentry path (method selection, as opposed to send-flow?method=cryptowhich skips the screen) had no test;withdraw-states.test.tsxmocks outAddWithdrawRouterViewentirely.da943d68dwas verified against the success-flow race it fixed, not against the pre-amount entry that shares the same guard + cleanup.Prevention: the new tests pin both behaviors: crypto selection must not navigate pre-amount, and user-object identity churn must not override an explicit view choice.
Summary by CodeRabbit
Bug Fixes
Tests