Expensify Card promotion banner conditional display#57218
Expensify Card promotion banner conditional display#57218mountiny merged 4 commits intoExpensify:mainfrom
Conversation
|
|
||
| const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.delegatedAccess?.delegate}); | ||
| const [isNoDelegateAccessMenuVisible, setIsNoDelegateAccessMenuVisible] = useState(false); | ||
| const shouldShowExpensifyCardPromotionBanner = !hasIssuedExpensifyCard(policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID); |
There was a problem hiding this comment.
| const shouldShowExpensifyCardPromotionBanner = !hasIssuedExpensifyCard(policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID); | |
| const [allWorkspaceCards] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST); | |
| const shouldShowExpensifyCardPromotionBanner = !hasIssuedExpensifyCard(policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID, allWorkspaceCards); |
Ideally, we should subscribe to the key ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST in this component and pass the cards to the function. Without that, React does not know this component needs to be re-rendered when workspace cards change.
This is not a problem in our present case because the user should switch back to Company Cards after adding an Expensify Card → the Company Cards page rerenders → it works fine.
Since we added an argument for hasIssuedExpensifyCard for testing purposes anyway, we can implement this suggestion.
This issue is clear when we add a card in a different tab and check back on the initial tab’s Company Cards page.
With the present code:
OnyxConnect.mov
Subscribing to the workspace cards key and passing the workspace cards to the function:
useOnyx.mov
Reviewer Checklist
Screenshots/VideosAndroid: NativeexpAndroid.movAndroid: mWeb ChromeiOS: NativeexpiOS.moviOS: mWeb SafariMacOS: Chrome / SafariexpChrome.movMacOS: DesktopexpDesktop.mov |
|
Everything looks good, but adding a parameter to the function specifically for testing looks a bit odd to me. I have a suggestion here to pass the workspace cards to the function to ensure proper reactivity, which also removes this oddity. |
|
Got it, will let you know once I applied the changes 👍 |
…7-expensifyCardBannerDisplay
|
@c3024 Changes mentioned in #57218 (comment) make total sense, thank you for the thorough review 🚀 🟢 Applied the suggested changes, this is ready for final review & merge (cc @mountiny). |
…7-expensifyCardBannerDisplay
|
✋ 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/mountiny in version: 9.1.6-0 🚀
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.6-0 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.1.6-1 🚀
|
Explanation of Change
New feature PR: #56561
♻️ Add-on follow-up functionaloty for the new feature PR mentioned above, requested by @mountiny in this Slack thread.
🗒️ The PR implements logic which checks whether there's an Expensify Card already issued for a workspace and if
truewe won't be showing the Expensify Card promotion banner in workspace > Company cards page anymore. For this we added a new function to CardUtils:hasIssuedExpensifyCard🧪 All other changes are due to eslint named imports rule since there were changes in those files.
@c3024 should be reviewing this PR since it's a follow-up of the initial PR.
Fixed Issues
$ #56485
PROPOSAL:
Tests
Precondition: Have a workspace with bank account added in order to be allowed to add physical / virtual Expensify Cards.
Company cardsand verify that the Expensify Card promotion banner is visible.Learn moreon the Expensify Card promotion banner and verify that theExpensify Cardfeature was enabled.Expensify Cardpage add a Virtual card and confirm it.Company cardspage and verify that the Expensify Card promotion banner is no longer displayed because the user already has an Expensify Card added.Offline tests
N/A.
QA Steps
Same as Tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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
web.mov
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop