Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/hooks/useIdentityVerification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,21 @@ export const useIdentityVerification = () => {

// helper to check if a region should be unlocked
const isRegionUnlocked = (regionName: string) => {
// sumsub approval scoped by the regionIntent used during verification.
// 'LATAM' intent → unlocks LATAM. 'STANDARD' intent → unlocks Bridge regions.
// rest of world is always unlocked with any sumsub approval (crypto features).
// provider-specific regions require the provider rails to be functional
// (not still PENDING from submission or FAILED).
if (isSumsubApproved) {
if (regionName === 'Rest of the world') return true
if (sumsubVerificationRegionIntent === 'LATAM') {
// LATAM is always unlocked for LATAM-intent sumsub users
// (QR payments work without manteca rails via superuser fallback)
if (MANTECA_SUPPORTED_REGIONS.includes(regionName)) return true
return false

// bridge regions: check provider rails regardless of sumsub regionIntent
if (BRIDGE_SUPPORTED_REGIONS.includes(regionName)) {
return hasProviderAccess('BRIDGE')
}
Comment on lines +182 to +185
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.

⚠️ Potential issue | 🟠 Major

Reuse the new Bridge-access predicate for the country-level Bridge unlocks.

Lines 182-185 now restore the top-level Bridge regions from hasProviderAccess('BRIDGE'), but Lines 206-208 still suppress BRIDGE_SUPPORTED_LATAM_COUNTRIES and MANTECA_QR_ONLY_REGIONS whenever isSumsubApproved is true. Sumsub-approved Bridge users will therefore still miss Mexico and the Bridge QR-only countries in unlockedRegions, even though this hook still advertises them as Bridge unlocks at Lines 250-283.

Suggested alignment
         const hasProviderAccess = (providerCode: string) => {
             const providerRails = user?.rails?.filter((r) => r.rail.provider.code === providerCode) ?? []
             if (providerRails.length === 0) return false
             return providerRails.some(
                 (r) =>
                     r.status === 'ENABLED' ||
                     r.status === 'REQUIRES_INFORMATION' ||
                     r.status === 'REQUIRES_EXTRA_INFORMATION'
             )
         }
+        const hasBridgeRailAccess = hasProviderAccess('BRIDGE')

         // helper to check if a region should be unlocked
         const isRegionUnlocked = (regionName: string) => {
             if (isSumsubApproved) {
                 if (regionName === 'Rest of the world') return true

                 // bridge regions: check provider rails regardless of sumsub regionIntent
                 if (BRIDGE_SUPPORTED_REGIONS.includes(regionName)) {
-                    return hasProviderAccess('BRIDGE')
+                    return hasBridgeRailAccess
                 }
@@
-        if (isBridgeApproved && !isMantecaApproved && !isSumsubApproved) {
+        if (((!isSumsubApproved && isBridgeApproved) || (isSumsubApproved && hasBridgeRailAccess)) && !isMantecaApproved) {
             unlocked.push(...MANTECA_QR_ONLY_REGIONS, ...BRIDGE_SUPPORTED_LATAM_COUNTRIES)
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// bridge regions: check provider rails regardless of sumsub regionIntent
if (BRIDGE_SUPPORTED_REGIONS.includes(regionName)) {
return hasProviderAccess('BRIDGE')
}
const hasProviderAccess = (providerCode: string) => {
const providerRails = user?.rails?.filter((r) => r.rail.provider.code === providerCode) ?? []
if (providerRails.length === 0) return false
return providerRails.some(
(r) =>
r.status === 'ENABLED' ||
r.status === 'REQUIRES_INFORMATION' ||
r.status === 'REQUIRES_EXTRA_INFORMATION'
)
}
const hasBridgeRailAccess = hasProviderAccess('BRIDGE')
// helper to check if a region should be unlocked
const isRegionUnlocked = (regionName: string) => {
if (isSumsubApproved) {
if (regionName === 'Rest of the world') return true
// bridge regions: check provider rails regardless of sumsub regionIntent
if (BRIDGE_SUPPORTED_REGIONS.includes(regionName)) {
return hasBridgeRailAccess
}
}
// ... rest of isRegionUnlocked logic
}
// ... middle code ...
if (((!isSumsubApproved && isBridgeApproved) || (isSumsubApproved && hasBridgeRailAccess)) && !isMantecaApproved) {
unlocked.push(...MANTECA_QR_ONLY_REGIONS, ...BRIDGE_SUPPORTED_LATAM_COUNTRIES)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useIdentityVerification.tsx` around lines 182 - 185, The hook
currently restores top-level Bridge regions via BRIDGE_SUPPORTED_REGIONS and
hasProviderAccess('BRIDGE') but still suppresses
BRIDGE_SUPPORTED_LATAM_COUNTRIES and MANTECA_QR_ONLY_REGIONS when
isSumsubApproved is true, causing Sumsub-approved Bridge users to miss Mexico
and QR-only countries in unlockedRegions; update the country-level conditional
that currently checks isSumsubApproved to instead (or additionally) consult
hasProviderAccess('BRIDGE') so that BRIDGE_SUPPORTED_LATAM_COUNTRIES and
MANTECA_QR_ONLY_REGIONS are included in unlockedRegions when
hasProviderAccess('BRIDGE') returns true (use the same predicate used for
BRIDGE_SUPPORTED_REGIONS and reference variables
BRIDGE_SUPPORTED_LATAM_COUNTRIES, MANTECA_QR_ONLY_REGIONS, isSumsubApproved,
hasProviderAccess('BRIDGE'), and unlockedRegions to locate and change the
logic).


// latam: unlocked when sumsub intent is LATAM (manteca submission
// happens after sumsub approval, rails may still be pending)
if (MANTECA_SUPPORTED_REGIONS.includes(regionName)) {
return sumsubVerificationRegionIntent === 'LATAM' || isMantecaApproved
}
return hasProviderAccess('BRIDGE') && BRIDGE_SUPPORTED_REGIONS.includes(regionName)

return false
}
return (
(isBridgeApproved && BRIDGE_SUPPORTED_REGIONS.includes(regionName)) ||
Expand Down
Loading