-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expensify Card promotion banner conditional display #57218
Expensify Card promotion banner conditional display #57218
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart for this small change suggested!
@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
true
we 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 cards
and verify that the Expensify Card promotion banner is visible.Learn more
on the Expensify Card promotion banner and verify that theExpensify Card
feature was enabled.Expensify Card
page add a Virtual card and confirm it.Company cards
page 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
web.mov
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop