Hide PIN when using USD cards#72488
Conversation
|
@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| const shouldShowReportLostCardButton = currentPhysicalCard?.state === CONST.EXPENSIFY_CARD.STATE.NOT_ACTIVATED || currentPhysicalCard?.state === CONST.EXPENSIFY_CARD.STATE.OPEN; | ||
|
|
||
| const currency = getCurrencyKeyByCountryCode(currencyList, cardsToShow?.at(0)?.nameValuePairs?.feedCountry); | ||
| const shouldShowPIN = currency !== CONST.CURRENCY.USD; |
There was a problem hiding this comment.
❌ PERF-6 (docs)
The shouldShowPIN calculation is executed on every render, even though it only depends on a specific property of the cardsToShow array. This can be optimized by memoizing the calculation.
Consider using useMemo to optimize this:
const shouldShowPIN = useMemo(() => {
const feedCountry = cardsToShow?.at(0)?.nameValuePairs?.feedCountry;
const currency = getCurrencyKeyByCountryCode(currencyList, feedCountry);
return currency !== CONST.CURRENCY.USD;
}, [currencyList, cardsToShow]);This ensures the calculation only runs when the actual dependencies change, not on every render.
|
@danieldoglas |
|
@ZhenjaHorbach, please review it! Price will be $125 on this one, since it's a pretty simple change. |
Reviewer Checklist
Screenshots/Videos |
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 47 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
@ZhenjaHorbach I've added an automated test too, sorry for pushing after you started the review. |
|
@danieldoglas |
|
Cool, I finally figured out. @ZhenjaHorbach I think this will pass now, all yours! |
|
LGTM! |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/danieldoglas in version: 9.2.30-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.2.30-6 🚀
|




Explanation of Change
For USD cards, we should not be showing the PIN option. This PR hides the PIN in the Expensify Card page.
Fixed Issues
$ #72487
PROPOSAL: N/A
Tests
Verify that no errors appear in the JS console
Have an account with an Expensify card on it
Go to the Expensify card details page
Confirm that the
PINoption is not present for USD cards.Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop