Skip to content
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

Add Expensify Card promoting banner to Company cards page #56561

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ikevin127
Copy link
Contributor

Explanation of Change

We want to make sure we promote the Expensify Card to customers who have the company cards or seeking this setup, this PR implements a promotional banner to the Company cards page such that:

  • when the admin clicks on the Learn more button we should take them to Expensify Card page
  • if the feature is not enabled, also optimistically enable it and call the api to enable the feature, then navigate to the Expensify Card page

Fixed Issues

$ #56485
PROPOSAL: #56485 (comment)

Tests

Precondition: Login and create a new workspace.

Test A (Expensify Card - Disabled)

  1. Navigate to workspace settings > More features > enable Company cards.
  2. Navigate to Company cards and notice the new Expensify Card promoting banner.
  3. Tap on the banner's Learn more button.
  4. Verify that this will enable the workspace's Expensify Card feature and navigate the user to it.
  5. Navigate back to the Company cards page and verify that the banner doesn't show up anymore.

Test B (Expensify Card - Enabled)

  1. Navigate to workspace settings > More features > enable both Company cards and Expensify Card features.
  2. Navigate to Company cards and notice the new Expensify Card promoting banner.
  3. Tap on the banner's Learn more button.
  4. Verify that this will navigate the user to the already enabled workspace Expensify Card feature page.
  5. Navigate back to the Company cards page and verify that the banner doesn't show up anymore.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests.

QA Steps

Same as Tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.webm
Android: mWeb Chrome
android-mweb.webm
iOS: Native
ios.mp4
iOS: mWeb Safari
ios-mweb.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov

@ikevin127 ikevin127 requested review from a team as code owners February 7, 2025 22:57
@melvin-bot melvin-bot bot requested a review from c3024 February 7, 2025 22:57
Copy link

melvin-bot bot commented Feb 7, 2025

@c3024 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]

@melvin-bot melvin-bot bot removed the request for review from a team February 7, 2025 22:57
@ikevin127
Copy link
Contributor Author

Here's something to sort out before we merge this: currently I am using Onyx to store a boolean value locally based on which I decide to show / hide the banner - this value is set to true whenever the banner's Learn more button is pressed the first time.

⚠ Issue with this is:

  • the variable is global, meaning once the banner Learn more button was pressed on Workspace A and the variable becomes true, the banner won't show up again in any workspace (even a newly created one)

I. Since this 'has already been clicked' logic wasn't mentioned or required in the issue's OP, we can:

  1. Remove the logic, therefore always showing the banner even after the Learn more button was pressed.
  2. Keep the logic, but make it workspace specific - meaning we will store both policyID and the boolean value in order to fix the issue mentioned above.
  3. (current behaviour) Keep the current logic as described above in the (⚠ Issue).

II. With this local Onyx variable there's one more thing to consider: when the user will press Settings > Trubleshooting > Clear cache and restart this will clear all local Onyx data, (depending on what we decide above) do we want to:

  1. Add the new key to KEYS_TO_PRESERVE in order to maintain the data and keep the Expensify Card promoting banner hidden even after user performs Clear cache and restart.
  2. (current behaviour) Don't preserve the new key, which will show the Expensify Card promoting banner after user performs Clear cache and restart.

cc @mountiny @c3024

@shawnborton
Copy link
Contributor

Nice! The videos look pretty good to me 👍

@dubielzyk-expensify
Copy link
Contributor

dubielzyk-expensify commented Feb 7, 2025

This looks great. Can I ask what the back stack is? If you click back after clicking Learn more Expensify Card, then you go back to Company Card again? Part of me was wondering if we should make it so you click back to More Features, but maybe that's weird or needlessly complicated

@dannymcclain
Copy link
Contributor

One question for @Expensify/design is if we want to theme these banners for light and dark mode?

For the subscription banners, we do have different styles for light vs dark—do we want to carry that through here as well?
image

@dubielzyk-expensify
Copy link
Contributor

Yeah I kinda think we should theme it cause it's VERY bright in dark mode there. I like that Danny!

@ikevin127
Copy link
Contributor Author

If you click back after clicking Learn more Expensify Card, then you go back to Company Card again?

@dubielzyk-expensify Correct, that's how it works on all platforms - seems logical to me in terms of navigation flow.

Screen.Recording.2025-02-07.at.15.20.45.mov

Part of me was wondering if we should make it so you click back to More Features, but maybe that's weird or needlessly complicated

I'm sure it can be done by replacing the Company cards route in the navigation stack with the More features route , just not sure that's what we want in this case, but if we decide for that let me know and I'll get to it.

@shawnborton
Copy link
Contributor

Super down with that!

@ikevin127
Copy link
Contributor Author

@Expensify/design Does this look good ? I noticed that the title / subtitle text color in the issue's OP (this design) is a dark green, whereas with what you can see below: I used already existing styles that we use in the SubscriptionBillingBanner illustrated in #56561 (comment) (which must be the design).

Screenshot 2025-02-07 at 16 07 50 Screenshot 2025-02-07 at 16 07 20

@dubielzyk-expensify
Copy link
Contributor

Let's just make both pieces of text be text-primary color:

image

cc @Expensify/design

@shawnborton
Copy link
Contributor

I agree with that!

@c3024
Copy link
Contributor

c3024 commented Feb 8, 2025

@vit @mountiny

W.r.t @ikevin127’s comment here, the OP does not specify whether we remove the banner after a user clicks on “Learn more” once. We keep the banner on the Company Cards page even after the user clicks on “Learn more,” right?

@@ -1080,6 +1081,13 @@ function goBackWhenEnableFeature(policyID: string) {
}, CONST.WORKSPACE_ENABLE_FEATURE_REDIRECT_DELAY);
}

function navigateToExpensifyCardPage(policyID: string) {
setTimeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setTimeout(() => {

I think we need not use setTimeout here. It looks like we are using setTimeout for navigating the user back to workspace initial page with goBackWhenEnableFeature only for narrow layouts after enabling a feature. setTimeout does not seem to serve any purpose here.

@@ -2896,6 +2904,12 @@ function enableExpensifyCard(policyID: string, enabled: boolean) {

API.write(WRITE_COMMANDS.ENABLE_POLICY_EXPENSIFY_CARDS, parameters, onyxData);

if (enabled && shouldNavigateToExpensifyCardPage) {
navigateToExpensifyCardPage(policyID);
setHasSeenExpensifyCardPromotionBanner();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setHasSeenExpensifyCardPromotionBanner();

We are already calling setHasSeenExpensifyCardPromotionBanner in navigateToExpensifyCardPage.

@@ -2849,7 +2850,14 @@ function savePreferredExportMethod(policyID: string, exportMethod: ReportExportT
Onyx.merge(`${ONYXKEYS.LAST_EXPORT_METHOD}`, {[policyID]: exportMethod});
}

function enableExpensifyCard(policyID: string, enabled: boolean) {
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompanyCards.clearAddNewCardFlow();
Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS_ADD_NEW.getRoute(policy?.id ?? '-1'));
clearAddNewCardFlow();
Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS_ADD_NEW.getRoute(policy?.id ?? String(CONST.DEFAULT_NUMBER_ID)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not default string IDs to any value.

@@ -1080,6 +1081,13 @@ function goBackWhenEnableFeature(policyID: string) {
}, CONST.WORKSPACE_ENABLE_FEATURE_REDIRECT_DELAY);
}

function navigateToExpensifyCardPage(policyID: string) {
setTimeout(() => {
Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID));
Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID)));

If this is added to prevent the brief “not found” page because the navigation action might have occurred before the Onyx update enabling the Expensify Cards page, we can add the navigation task to the microtask queue to ensure it happens only after the Onyx update using setNavigationActionToMicrotaskQueue and avoid using setTimeout.

@ikevin127
Copy link
Contributor Author

@Expensify/design Addressed the latest text style change request, here's how it looks now:

@c3024 Addressed all code related change requests (👍), all that's left to decide regarding the logic is what I asked in #56561 (comment) and you reiterated in #56561 (comment).

@mountiny
Copy link
Contributor

mountiny commented Feb 9, 2025

the OP does not specify whether we remove the banner after a user clicks on “Learn more” once. We keep the banner on the Company Cards page even after the user clicks on “Learn more,” right?

Right, I dont think we need this logic, we should show the banner all the time until they add a card feed - then the ui changes and we would not promote for the card with this pattern (we could add something more later but that is not in scope of this project)

@ikevin127
Copy link
Contributor Author

Right, I dont think we need this logic, we should show the banner all the time until they add a card feed - then the ui changes and we would not promote for the card with this pattern (we could add something more later but that is not in scope of this project)

✅ Done, makes total sense - thanks for jumping in over the weekend 🚀

  • ☑️ all previous PR review comments / change requests are implemented
  • ☑️ #56561 (comment) was resolved, we decided to remove local Onyx variable and show the banner at all times in the WorkspaceCompanyCardPageEmptyState page
  • ☑️ design changes requested in #56561 (comment) are now up to date and implemented as displayed in #56561 (comment)

@c3024 PR is 💯% ready for review!

@dubielzyk-expensify
Copy link
Contributor

@Expensify/design Addressed the latest text style change request, here's how it looks now:

That looks løvely! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants