Skip to content

feat(kyc): show a region screen instead of a support dead end - #2778

Closed
innolope-dev wants to merge 3 commits into
devfrom
claude/kyc-rejection-screen-ru-cn-hk-0z0a4n
Closed

feat(kyc): show a region screen instead of a support dead end#2778
innolope-dev wants to merge 3 commits into
devfrom
claude/kyc-rejection-screen-ru-cn-hk-0z0a4n

Conversation

@innolope-dev

Copy link
Copy Markdown
Collaborator

Same branch as #2775, targeting dev instead of main. Merge one, close the other — they are the identical three commits.

Backend: peanutprotocol/peanut-api-ts#1381.

What this does

A user whose ID is rejected for its jurisdiction currently hits one of four endings, none of them honest:

Surface Today Ending
Home activation card "Verification issue — Contact support" Ticket nobody can resolve
Identity row → drawer "Retry verification" Retry that can never pass
/profile/identity-verification "Let's try that again" Retry that can never pass
Add-money / withdraw bank gate "We couldn't unlock this — contact support" Ticket nobody can resolve

All four are replaced by one screen: explains the block, names no country, offers no retry, offers no support link, and hands the user the part of the app that still works.

We can't verify IDs from your country

Our verification partner doesn't accept documents issued in your country. Re-uploading won't change the result.

Your funds are safe, and you can still use Peanut to send and receive money with other people.

[ Send or request money ]

Two different endings, deliberately

The third commit fixes a separate pre-existing bug found while building this, and the two cases are deliberately handled differently:

Region-restricted Fraud / sanctions / age / forgery
Explain the cause? Yes, fully No — compliance exposure, and it tips off actual fraudsters
Can support help? No — it cannot lift a jurisdictional block Yes — a human can review a misclassification
Retry offered? No No
Ending Explanation + "Send or request money" Generic + Contact support

The pre-existing bug: UnlockedRegions.view.tsx hardcoded all three of isTerminalRejection's inputs to null/undefined during the capabilities migration, so the check always returned "retryable". Every terminal rejection — fraud, sanctions, age — has been showing "Let's try that again" on that page. The drawer never had a terminal branch at all. Both now read the backend's verdict instead of reconstructing it from raw labels and attempt counts.

Enforced at the choke point

Six gates open InitiateKycModal, each computing its variant from a rail gate that cannot see why identity failed — a region-restricted user reads as needs-identity and would be offered "Unlock now" straight back into the Sumsub SDK. The short-circuit lives inside the shared component, so a future call site cannot miss it. Tested against all five variants.

Deploy-order safety

isRegionRestricted requires identityVerification.reason, which only the backend PR emits. If this ships first, the region screen simply never renders — every region path stays exactly as it is today. Nothing breaks.

The terminal fix is different and does take effect immediately, by design: isTerminalFailure treats a missing canRetry as terminal (fail-closed), on the grounds that offering a retry which cannot pass is worse than a support link that wasn't strictly needed. So the fraud/sanctions retry loop is fixed on FE deploy regardless of backend timing. The only cost in that window is the small reviewAnswer: ERROR cohort losing their (legitimate) retry until the backend ships. Say the word if you'd rather default the other way — it's one operator in useIdentityVerification.

Verification

  • 31 new tests — 20 on the region screens (contract assertions run against every surface via describe.each, so drawer and modal can't drift), 8 on the hook, 3 on the home card.
  • src/components, src/hooks, src/utils, src/i18n: 2835 passed. One pre-existing failure in Invites/badge-campaign-context.test.ts — fails identically on main, and passes in CI.
  • CI on the main PR: 3404 unit tests, 0 failed; typecheck, eslint, format, e2e all green.
  • Copy added to all four locales, respecting each register (es-AR voseo, es-419 tuteo). No country named in any of them.

Review focus

  1. Is peer-to-peer actually open for a Sumsub-rejected user? The copy promises it. This PR doesn't gate anything, but it depends on that being true.
  2. Is /send the right destination, or would /home be safer for a cohort likely holding no balance?
  3. The fail-closed canRetry default described above.

Generated by Claude Code

claude added 3 commits August 20, 2026 20:44
A user whose ID was rejected for its jurisdiction hits one of four
endings today, and none of them is honest. Two offer a retry that can
never pass (the drawer's "Retry verification"; the identity-verification
page's "Let's try that again"), and two route to support over a block
support cannot lift (the home card; the bank gates' "We couldn't unlock
this").

Replace all four with one screen that explains the block, names no
country, offers no retry, offers no support link, and hands the user the
part of the app that still works.

The CTA is the design decision. With retry and support both gone, the
button's only remaining job is to point at a capability the user keeps —
so it routes to send/request rather than dismissing. That is also the
promise the copy makes, so peer-to-peer must stay open for this cohort;
this change does not gate anything, but it does depend on that.

Enforced at the choke point, not per call site. Six gates open
InitiateKycModal, and each computes its variant from a rail gate that
cannot see WHY identity failed — a region-restricted user reads as
`needs-identity` and would be offered "Unlock now" straight back into
the Sumsub SDK. Short-circuiting inside the shared component makes that
impossible for a future call site to miss.

Also marks the two region reject labels terminal, so no surviving
surface can contradict the new screen with a retry button. That fixes a
pre-existing bug beyond this cohort: UnlockedRegions hardcodes
isTerminalRejection's three inputs to null (a documented casualty of the
capabilities migration), so EVERY terminal rejection — fraud, sanctions,
age — currently renders "Let's try that again" there.

Copy names no country in any of the four locales, so a change to the
Sumsub list needs no re-translation and no deploy.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EEmE861AXBaoE1y31ChW6e
The InitiateKycModal short-circuit re-implemented KycRegionRestrictedModal
inline — same title, icon, content and CTA, ~30 lines of it. Call the
component instead.

Duplication was the point, not the line count: the whole change rests on
every surface telling a region-restricted user the same thing, and two
independent definitions of that screen are two things that can drift.
Now there is one.

Caught by the code-analysis bot flagging InitiateKycModal's MDD jump
(41.5 → 55.5) on the first push.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EEmE861AXBaoE1y31ChW6e
Every terminal rejection — fraud, sanctions, age, forgery — currently
shows "Let's try that again" on /profile/identity-verification, and a
"Retry verification" button in the identity drawer. Neither can pass.

Root cause: UnlockedRegions hardcoded all three of isTerminalRejection's
inputs to null/undefined during the capabilities migration, because the
capability model carries no per-verification Sumsub history. The check
therefore always returned "retryable" and the terminal branch never
rendered. The drawer never had a terminal branch at all.

The history was never the right source. The backend already folds the
decision (Sumsub RETRY → ACTION_REQUIRED, FINAL → REJECTED) and now says
outright whether a retry is worth offering, so read that instead of
reconstructing it from raw labels and attempt counts.

These get a DIFFERENT ending from region-restricted, deliberately:

  region-restricted  explain fully, no support link — support cannot
                     lift a jurisdictional block
  terminal           explain nothing, offer support — naming fraud or
                     sanctions carries compliance exposure and tips off
                     the people it describes, and a human CAN review a
                     misclassification

Both are terminal, so neither offers a retry.

Also guards the home card banner on isRegionRestricted: that branch
returns before reading `step`, so the region card was silently replaced
by a CTA routing to /shhhhh.

KycFailed takes onContactSupport as a prop rather than reading
ModalsContext, keeping it presentational like its siblings — reading the
context directly broke an unrelated suite that renders it bare.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EEmE861AXBaoE1y31ChW6e
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peanut-wallet Building Building Preview Aug 20, 2026 9:06pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 018c6844-441e-475d-9b82-4223f73b92c9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 7313.46 → 7336.49 (+23.03)
Findings: +10 net (+50 new, -40 resolved)

🆕 New findings (50)

  • critical complexity — src/components/Home/ActivationCTAs.tsx — CC 71, MI 57.06, SLOC 288
  • critical complexity — src/components/Profile/views/UnlockedRegions.view.tsx — CC 66, MI 59.64, SLOC 219
  • high complexity — src/components/Kyc/InitiateKycModal.tsx — CC 48, MI 51.37, SLOC 126
  • high hotspot — src/components/Home/ActivationCTAs.tsx — 32 commits, +706/-253 lines since 6 months ago
  • high method-complexity — src/components/Profile/views/UnlockedRegions.view.tsx:68 — CC 30 SLOC 149
  • medium high-mdd — src/components/Profile/views/UnlockedRegions.view.tsx:68 — UnlockedRegions: MDD 122.4 (uses across many lines from declarations)
  • medium high-mdd — src/components/Home/ActivationCTAs.tsx:49 — ActivationCTAs: MDD 115.8 (uses across many lines from declarations)
  • medium structural-dup — types/api.generated.ts:7 — 48 duplicate lines / 185 tokens with types/api.generated.ts:10931
  • medium high-mdd — src/components/Kyc/InitiateKycModal.tsx:36 — InitiateKycModal: MDD 47.3 (uses across many lines from declarations)
  • medium structural-dup — types/api.generated.ts:267 — 38 duplicate lines / 141 tokens with types/api.generated.ts:11200
  • medium structural-dup — types/api.generated.ts:267 — 36 duplicate lines / 127 tokens with types/api.generated.ts:11095
  • medium structural-dup — types/api.generated.ts:267 — 36 duplicate lines / 127 tokens with types/api.generated.ts:11167
  • medium structural-dup — types/api.generated.ts:267 — 36 duplicate lines / 127 tokens with types/api.generated.ts:11239
  • medium high-dlt — src/components/Home/ActivationCTAs.tsx:49 — ActivationCTAs: DLT 35 (calls 35 distinct functions — high context load)
  • medium high-mdd — src/components/Kyc/KycStatusDrawer.tsx:25 — KycStatusDrawer: MDD 34.6 (uses across many lines from declarations)
  • medium structural-dup — types/api.generated.ts:11014 — 35 duplicate lines / 131 tokens with types/api.generated.ts:11272
  • medium high-dlt — src/components/Profile/views/UnlockedRegions.view.tsx:68 — UnlockedRegions: DLT 34 (calls 34 distinct functions — high context load)
  • medium structural-dup — types/api.generated.ts:7 — 33 duplicate lines / 127 tokens with types/api.generated.ts:10981
  • medium structural-dup — types/api.generated.ts:40 — 30 duplicate lines / 131 tokens with types/api.generated.ts:10896
  • medium structural-dup — types/api.generated.ts:532 — 25 duplicate lines / 84 tokens with types/api.generated.ts:11026

…and 30 more.

✅ Resolved (40)

  • src/components/Home/ActivationCTAs.tsx — CC 68, MI 57.81, SLOC 271
  • src/components/Profile/views/UnlockedRegions.view.tsx — CC 63, MI 59.97, SLOC 214
  • src/components/Kyc/InitiateKycModal.tsx — CC 47, MI 51.83, SLOC 121
  • src/components/Home/ActivationCTAs.tsx — 30 commits, +668/-250 lines since 6 months ago
  • src/components/Profile/views/UnlockedRegions.view.tsx:66 — UnlockedRegions: MDD 117.2 (uses across many lines from declarations)
  • src/components/Home/ActivationCTAs.tsx:48 — ActivationCTAs: MDD 98.3 (uses across many lines from declarations)
  • types/api.generated.ts:7 — 48 duplicate lines / 185 tokens with types/api.generated.ts:10925
  • src/components/Kyc/InitiateKycModal.tsx:34 — InitiateKycModal: MDD 41.5 (uses across many lines from declarations)
  • types/api.generated.ts:267 — 38 duplicate lines / 141 tokens with types/api.generated.ts:11194
  • types/api.generated.ts:267 — 36 duplicate lines / 127 tokens with types/api.generated.ts:11089
  • types/api.generated.ts:267 — 36 duplicate lines / 127 tokens with types/api.generated.ts:11161
  • types/api.generated.ts:267 — 36 duplicate lines / 127 tokens with types/api.generated.ts:11233
  • types/api.generated.ts:11008 — 35 duplicate lines / 131 tokens with types/api.generated.ts:11266
  • src/components/Home/ActivationCTAs.tsx:48 — ActivationCTAs: DLT 34 (calls 34 distinct functions — high context load)
  • src/components/Profile/views/UnlockedRegions.view.tsx:66 — UnlockedRegions: DLT 33 (calls 33 distinct functions — high context load)
  • types/api.generated.ts:7 — 33 duplicate lines / 127 tokens with types/api.generated.ts:10975
  • src/components/Kyc/KycStatusDrawer.tsx:23 — KycStatusDrawer: MDD 31.4 (uses across many lines from declarations)
  • types/api.generated.ts:40 — 30 duplicate lines / 131 tokens with types/api.generated.ts:10890
  • src/components/Profile/views/UnlockedRegions.view.tsx:66 — CC 27 SLOC 144
  • types/api.generated.ts:532 — 25 duplicate lines / 84 tokens with types/api.generated.ts:11020

…and 20 more.

📈 Painscore deltas (top movers)

File Before After Δ
src/components/Kyc/states/KycRegionRestricted.tsx 0.0 7.8 +7.8
src/components/Kyc/KycRegionRestrictedContent.tsx 0.0 6.0 +6.0
src/components/Kyc/modals/KycRegionRestrictedModal.tsx 0.0 6.0 +6.0
src/hooks/useIdentityVerification.ts 4.6 5.5 +0.9
src/components/Home/ActivationCTAs.tsx 12.6 13.1 +0.5

@github-actions

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 3480 ran, 0 failed, 0 skipped, 1.0m

📊 Coverage (unit)

metric %
statements 68.9%
branches 54.1%
functions 60.0%
lines 69.8%
⏱ 10 slowest test cases
time test
4.2s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
1.0s src/utils/__tests__/demo-api.test.ts › isDemoMode() is false when not running under Capacitor
1.0s src/hooks/query/__tests__/user.test.tsx › does NOT clear a token that rotated mid-request (stale 401 racing a fresh login)
0.6s src/utils/__tests__/crisp.test.ts › resets the native session on logout once support has been opened
0.5s src/utils/__tests__/sentry.utils.test.ts › defaults to the client budget under a browser global
0.5s src/utils/__tests__/auth-token.test.ts › authReady does not park — hydrates the plain token without an unlock
0.5s src/utils/__tests__/crisp.test.ts › settles, and hands back a usable plugin, against a real-shaped plugin proxy
0.4s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.4s src/utils/__tests__/crisp.test.ts › configures once across repeated support opens
0.4s src/i18n/__tests__/messages.test.ts › en has no empty or untrimmed values
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

innolope-dev pushed a commit that referenced this pull request Aug 21, 2026
The regions rework: regions survive as presentational groups, but every
row is a concrete product with a live status chip, and the unlock verb
attaches to products ("SEPA transfers · Unlock"), never to abstract
regions.

- Everywhere group leads: Peanut-to-Peanut payments (Always on) and the
  Peanut card as its own row routing to /card. The card is a global
  product gated by residence eligibility, not a regional rail — which
  removes the old screen's Europe-tap → /card hijack by construction
  (a bank-method tap can only start bank KYC; pinned by test).
- Region groups follow the rail's real geography: Brazil (PIX & bank
  transfers), Argentina (QR & transfers), United States (ACH & Wire),
  Mexico (SPEI), Europe (SEPA). LATAM never appears — it stays what it
  is, an internal KYC-level bucket. Rest-of-world's provider-less dead
  end is gone; the Everywhere group carries that meaning honestly.
- Merged rows split automatically when statuses diverge: a Bridge-only
  user sees "PIX QR payments · Active" + "Bank transfers · Unlock".
- Residence anchor row (declared/verified from the new /users/me
  residence block) explains why the list looks the way it does, and
  the user's own region floats to the top under Everywhere.
- Residence restrictions render as quiet honesty: restricted rows say
  Not available and stop being tappable; the always-on row survives.
- All KYC modal machinery (unlock/processing/action-required/rejected/
  provider-rejection, multi-phase flow) is carried over unchanged from
  UnlockedRegions.view, which stays in place untouched to avoid
  conflicting with PR #2778.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxUXJzMPSyKow6xpEYH8MA

Copy link
Copy Markdown
Collaborator Author

Closing: all three commits from this PR are merged unchanged into #2790, the joint onboarding PR targeting dev (the region-restricted interrupt was semantically merged with the new home checklist — it outranks it, pinned by test).


Generated by Claude Code

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.

2 participants