fix(rewards): use GeolocationController for mUSD card geo check#27746
Conversation
Use the actual GeolocationController state instead of rewards Redux state to determine mUSD card visibility. This prevents a flash of the mUSD card for UK users when the card slice loads before the geo check. Changes: - Use selectGeolocationLocation and selectGeolocationStatus from GeolocationController instead of rewards selectors - Require positive geo confirmation (location must be defined, not 'UNKNOWN', and not 'GB') to show mUSD card - Handle all geo status states: 'idle', 'loading', 'complete', 'error' - Add UK_COUNTRY_CODE and UNKNOWN_LOCATION constants for clarity Made-with: Cursor
|
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
|
||
| const AVATAR_SIZE = 78; | ||
| const UK_COUNTRY_CODE = 'GB'; | ||
| const UNKNOWN_LOCATION = 'UNKNOWN'; |
There was a problem hiding this comment.
Hardcoded UNKNOWN_LOCATION duplicates package-exported constant
Low Severity
The local UNKNOWN_LOCATION = 'UNKNOWN' constant duplicates the same constant already exported by @metamask/geolocation-controller, which is imported and used in app/core/Engine/controllers/geolocation-controller/index.ts. If the package ever changes its sentinel value, this hardcoded copy would silently diverge, causing the geo check to miss the unknown-location case and potentially flashing the mUSD card for users whose location lookup failed.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|
✅ E2E Fixture Validation — Schema is up to date |
|





Description
Use the actual GeolocationController state instead of rewards Redux state to determine mUSD card visibility on the Rewards dashboard. This prevents a flash of the mUSD card for UK users when the card slice loads before the geo check completes.
Problem:
Previously,
showMusdCardwas derived asoptinAllowedForGeo !== false, treatingnull(initial/undetermined) the same astrue(allowed). The rewards Redux initial state hasoptinAllowedForGeoLoading: falseandoptinAllowedForGeo: null. When the card slice had already loaded but the rewards geo check hadn't started yet,isAnyGeoLoadingevaluated tofalsewhileshowMusdCardwastrue, causing the mUSD card to render briefly for UK users.Solution:
selectGeolocationLocationandselectGeolocationStatusfrom GeolocationControllerUK_COUNTRY_CODEandUNKNOWN_LOCATIONconstants for clarityChangelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Made with Cursor
Note
Low Risk
Low risk UI gating change that only affects when the mUSD rewards card renders; main risk is inadvertently hiding/showing the card for some geolocation edge cases (e.g., undefined/UNKNOWN/status handling).
Overview
Updates the Rewards dashboard
EarnRewardsPreviewto derive mUSD card visibility fromGeolocationController(selectGeolocationLocation/selectGeolocationStatus) instead of the rewards reducer’soptinAllowedForGeoflags.The mUSD card now renders only after a confirmed, known location and is explicitly hidden for
GBandUNKNOWN/undefinedlocations, treatingidle/loadingas a loading state to prevent a brief “flash” for UK users. Tests are updated to cover the newidle/loadingskeleton behavior and theundefined/UNKNOWN/GBhiding cases.Written by Cursor Bugbot for commit b466bbf. This will update automatically on new commits. Configure here.