feat(kyc): show a region screen instead of a support dead end - #2775
feat(kyc): show a region screen instead of a support dead end#2775innolope-dev wants to merge 3 commits into
Conversation
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 latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Included review availability: 2 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthroughThe PR adds region-restriction detection for identity verification, terminal KYC views and modals, localized messaging, direct ChangesRegion restriction handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to This PR replaces region-restricted verification dead ends with a localized explanation and a send/request-money path; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant User
participant IdentityVerification
participant KycStatusDrawer
participant KycRegionRestrictedModal
participant SendRoute
User->>IdentityVerification: receive failed status and restriction reason
IdentityVerification->>KycStatusDrawer: expose isRegionRestricted
KycStatusDrawer->>KycRegionRestrictedModal: render terminal restricted content
KycRegionRestrictedModal->>SendRoute: navigate to `/send`
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Code-analysis diffPainscore total: 7305.49 → 7328.59 (+23.1) 🆕 New findings (50)
…and 30 more. ✅ Resolved (40)
…and 20 more. 📈 Painscore deltas (top movers)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
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
There was a problem hiding this comment.
🔇 Additional comments (24)
src/types/api.openapi.json (1)
17881-17898: LGTM!src/types/capabilities.ts (1)
195-202: LGTM!src/constants/kyc.consts.ts (1)
14-25: LGTM!src/constants/capability-reason-labels.consts.ts (1)
49-51: LGTM!src/constants/sumsub-reject-labels.consts.ts (1)
106-113: 🗄️ Data Integrity & Integration
⚠️ Unverified finding
Sandbox verification was unavailable.Verify all consumers of the expanded terminal-label set.
This change makes
WRONG_USER_REGIONandREGULATIONS_VIOLATIONSterminal for every caller ofhasTerminalRejectLabelandisTerminalRejection, not only for the region-restricted screen. Confirm thatUnlockedRegions.view.tsxand any other consumer of these helpers now correctly suppress retry actions for these two labels, since that file is outside this review batch.src/hooks/useIdentityVerification.ts (1)
4-4: LGTM!Also applies to: 33-40, 57-60
src/hooks/__tests__/useIdentityVerification.regionRestricted.test.ts (1)
1-53: LGTM!src/components/Kyc/KycStatusDrawer.tsx (1)
4-4: LGTM!Also applies to: 25-25, 67-71
src/i18n/app/messages/pt-BR.json (2)
2232-2238: LGTM!
2603-2604: LGTM!src/components/Kyc/states/__tests__/KycRegionRestricted.test.tsx (4)
1-43: LGTM!
45-94: LGTM!
96-120: LGTM!
122-158: LGTM!src/components/Kyc/KycRegionRestrictedContent.tsx (1)
1-48: LGTM!src/components/Kyc/modals/KycRegionRestrictedModal.tsx (1)
1-46: LGTM!src/components/Kyc/states/KycRegionRestricted.tsx (1)
1-45: LGTM!src/components/Home/ActivationCTAs.tsx (2)
227-243: 🎯 Functional Correctness
⚠️ Unverified finding
Sandbox verification was unavailable.Validate the card-step bypass.
stepselects the region-restricted card here. The lateractivationStep === 'card'branch rendersCardLaunchCTABannerwithout checkingisRegionRestricted. If both states can coexist, its CTA routes to/shhhhhinstead of/send.Guard the special card branch with
!isRegionRestricted, or prove that this state combination is impossible. Add a regression test for the combination.
19-19: LGTM!Also applies to: 53-53, 67-71, 312-313, 351-356
src/components/Kyc/InitiateKycModal.tsx (1)
9-10: LGTM!Also applies to: 49-62, 144-170
src/components/Profile/views/UnlockedRegions.view.tsx (1)
14-21: LGTM!Also applies to: 80-84, 268-274
src/i18n/app/messages/en.json (1)
2232-2238: LGTM!Also applies to: 2603-2604
src/i18n/app/messages/es-419.json (1)
2232-2238: LGTM!Also applies to: 2603-2604
src/i18n/app/messages/es-AR.json (1)
800-806: LGTM!Also applies to: 1009-1010
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7bffd3fd-a0b0-4db8-8efc-858548f70b8c
⛔ Files ignored due to path filters (1)
src/types/api.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (19)
src/components/Home/ActivationCTAs.tsxsrc/components/Kyc/InitiateKycModal.tsxsrc/components/Kyc/KycRegionRestrictedContent.tsxsrc/components/Kyc/KycStatusDrawer.tsxsrc/components/Kyc/modals/KycRegionRestrictedModal.tsxsrc/components/Kyc/states/KycRegionRestricted.tsxsrc/components/Kyc/states/__tests__/KycRegionRestricted.test.tsxsrc/components/Profile/views/UnlockedRegions.view.tsxsrc/constants/capability-reason-labels.consts.tssrc/constants/kyc.consts.tssrc/constants/sumsub-reject-labels.consts.tssrc/hooks/__tests__/useIdentityVerification.regionRestricted.test.tssrc/hooks/useIdentityVerification.tssrc/i18n/app/messages/en.jsonsrc/i18n/app/messages/es-419.jsonsrc/i18n/app/messages/es-AR.jsonsrc/i18n/app/messages/pt-BR.jsonsrc/types/api.openapi.jsonsrc/types/capabilities.ts
Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.
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
|
Closing: this was the Generated by Claude Code |
Targets
main. A duplicate of this branch targetingdevis open as #2778 — 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:
/profile/identity-verificationAll 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.
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:
The pre-existing bug:
UnlockedRegions.view.tsxhardcoded all three ofisTerminalRejection's inputs tonull/undefinedduring 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 asneeds-identityand 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
isRegionRestrictedrequiresidentityVerification.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:
isTerminalFailuretreats a missingcanRetryas 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 smallreviewAnswer: ERRORcohort losing their (legitimate) retry until the backend ships. Say the word if you'd rather default the other way — it's one operator inuseIdentityVerification.Verification
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 inInvites/badge-campaign-context.test.ts— fails identically onmain, and passes in CI.Review focus
/sendthe right destination, or would/homebe safer for a cohort likely holding no balance?canRetrydefault described above.