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

[Free trial] Implement and show Trial Ended banner, Expensify DM GBR and custom Expensify DM chat item in the App after Free Trial ends #44483

Conversation

pac-guerreiro
Copy link
Contributor

@pac-guerreiro pac-guerreiro commented Jun 26, 2024

Details

Fixed Issues

$#43671
PROPOSAL: N/A

Tests

  1. Write this code on the browser console and get your accountID:
Onyx.log("session")
  1. If your accountID is a odd number, then the chat used to display the free trial ended will be the Expensify DM, otherwise it's the Concierge DM.
  2. Add the following code to Expensify.tsx in order to display the Free Trial ended message in the chat:
    useEffect(() => {
        const reportID = getChatUsedForOnboarding()?.reportID ?? '-1';
        const lastVisibleAction = getLastVisibleAction(reportID);
        if (lastVisibleAction && lastVisibleAction.actionName !== CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_ADD_PAYMENT_CARD) {
            Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getChatUsedForOnboarding()?.reportID}`, {
                111111: {
                    actionName: 'ACTIONABLEADDPAYMENTCARD',
                    actorAccountID: 8392101,
                    avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png',
                    created: lastVisibleAction.created,
                    lastModified: lastVisibleAction.lastModified,
                    message: [
                        {
                            html: '<h1>Free trial expired</h1>Your free trial has ended. Add a payment card to continue using all your favorite features.',
                            text: 'Free trial expired\nYour free trial has ended. Add a payment card to continue using all your favorite features.',
                            type: 'COMMENT',
                            whisperedTo: [],
                        },
                    ],
                    originalMessage: {},
                    person: [
                        {
                            style: 'strong',
                            text: 'Expensify Concierge',
                            type: 'TEXT',
                        },
                    ],
                    previousReportActionID: lastVisibleAction.reportActionID,
                    reportActionID: '111111',
                    shouldShow: true,
                },
            });
        }
    }, []);
  1. Check that the chat in LHN has a GBR and the preview message matches the text property from the report action you added in the previous step
  2. Open the report and check that it displays the message that the free trial ended and if you're running the app on mobile native, it doesn't show the action button to add payment card.
  3. In web/desktop, click on the add payment card button and confirm that you're redirected to the subscription page and are shown the free trial ended banner

Offline tests

Same as above

QA Steps

Only test on web and desktop for now. It'll be tricky for QA to test other platforms just yet. Once the feature is completely done we'll put the full steps for QA to test (or self test them).

WEB/DESKTOP

  1. Write this code on the browser console and get your accountID:
window.Onyx.log("session")
  1. If your accountID is a odd number, then the chat used to display the free trial ended will be the Expensify DM, otherwise it's the Concierge DM.
  2. Open the respective report and copy the reportID from the url
  3. Run the following commands on the browser console in order to display the Free Trial ended message in the chat:
Onyx.merge("nvp_private_firstDayFreeTrial", "2024-04-09 16:03:18")
Onyx.merge("nvp_private_lastDayFreeTrial", "2024-05-31 23:59:59")
   Onyx.merge('reportActions_<reportID>', {
                111111: {
                    actionName: 'ACTIONABLEADDPAYMENTCARD',
                    actorAccountID: 8392101,
                    avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png',
                    created: "yyyy-mm-dd hh:mm:ss", //replace with todays date
                    lastModified: "yyyy-mm-dd hh:mm:ss", //replace with todays date
                    message: [
                        {
                            html: '<h1>Free trial expired</h1>Your free trial has ended. Add a payment card to continue using all your favorite features.',
                            text: 'Free trial expired\nYour free trial has ended. Add a payment card to continue using all your favorite features.',
                            type: 'COMMENT',
                            whisperedTo: [],
                        },
                    ],
                    originalMessage: {},
                    person: [
                        {
                            style: 'strong',
                            text: 'Expensify Concierge',
                            type: 'TEXT',
                        },
                    ],
                    previousReportActionID: 0,
                    reportActionID: '111111',
                    shouldShow: true,
                },
            });
  1. Check that the chat in LHN has a GBR and the preview message matches the text property from the report action you added in the previous step.
  2. Open the report and check that it displays the message that the free trial ended.
  3. Click on the add payment card button and confirm that you're redirected to the subscription page and are shown the free trial ended banner.

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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • 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.js 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.
  • 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.-.Native.mp4
Android: mWeb Chrome
Android.-.Chrome.mp4
iOS: Native
iOS.-.Native.mp4
iOS: mWeb Safari
iOS.-.Safari.mp4
MacOS: Chrome / Safari
MacOS.-.Chrome.mp4
MacOS: Desktop
MacOS.-.Native.mp4

…al-banner-and-badges-after-free-trial-starts' into pac-guerreiro/feature/43671-trial-ended-banner-expensify-dm-gbr-and-custom-chat-item
…al-banner-and-badges-after-free-trial-starts' into pac-guerreiro/feature/43671-trial-ended-banner-expensify-dm-gbr-and-custom-chat-item
…al-banner-and-badges-after-free-trial-starts' into pac-guerreiro/feature/43671-trial-ended-banner-expensify-dm-gbr-and-custom-chat-item
src/languages/en.ts Outdated Show resolved Hide resolved
src/libs/ReportActionsUtils.ts Outdated Show resolved Hide resolved
src/libs/ReportActionsUtils.ts Outdated Show resolved Hide resolved
src/libs/shouldRenderAppPaymentCard/index.native.ts Outdated Show resolved Hide resolved
src/pages/home/report/ReportActionItem.tsx Show resolved Hide resolved
…al-banner-and-badges-after-free-trial-starts' into pac-guerreiro/feature/43671-trial-ended-banner-expensify-dm-gbr-and-custom-chat-item

# Conflicts:
#	src/libs/ReportActionsUtils.ts
…al-banner-and-badges-after-free-trial-starts' into pac-guerreiro/feature/43671-trial-ended-banner-expensify-dm-gbr-and-custom-chat-item

# Conflicts:
#	src/pages/settings/Subscription/CardSection/CardSection.tsx
@pac-guerreiro pac-guerreiro changed the title [WIP][Free trial] Implement and show Trial Ended banner, Expensify DM GBR and custom Expensify DM chat item in the App after Free Trial ends [Free trial] Implement and show Trial Ended banner, Expensify DM GBR and custom Expensify DM chat item in the App after Free Trial ends Jul 3, 2024
@pac-guerreiro pac-guerreiro marked this pull request as ready for review July 3, 2024 08:59
@pac-guerreiro pac-guerreiro requested review from a team as code owners July 3, 2024 08:59
@melvin-bot melvin-bot bot requested review from rojiphil and removed request for a team July 3, 2024 08:59
Copy link

melvin-bot bot commented Jul 3, 2024

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

@shawnborton
Copy link
Contributor

Looking good to me. Just wanted to confirm with @Expensify/design and @MitchExpensify - we decided not to put any kind of GBR on the bottom Settings tab, right?

@trjExpensify
Copy link
Contributor

From the doc, it doesn't look like it. When the free trial ends a message will be sent in the Conci/onboarding DM with a CTA green button to add a payment card, so a GBR is added to the chat. I think the Inbox bottom tab will get GBR'd "for free" because of that with the existing logic for GBR'd chats. The issue for adding that message hasn't be completed yet: #43694

@dannymcclain
Copy link
Contributor

we decided not to put any kind of GBR on the bottom Settings tab, right?

Yeah like Tom said, I think we decided to only use the one from Inbox.

@shawnborton
Copy link
Contributor

Okay cool, I wasn't sure where we landed with that. I don't think we need to change anything here but it does seem like a strange detour to GBR the Inbox when the action that needs to be taken happens in Settings... but I'll rest my case there for now :)

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

@pac-guerreiro Thanks for the PR.

I have left one comment otherwise the code looks good. Additionally, I also have following observations:

  1. The subtitle text for Concierge Chat Report in LHN does not reflect the text from actionable add payment. The same problem occurs for Expensify Chat Report.
  2. The GBR shows up for Expensify Chat Report but does not show for Concierge Chat Report in LHN for trial ended case.

Please have a look on these as well.

Concierge Screenshot
Screenshot 2024-07-04 at 1 03 51 PM

Expensify Screenshot
Screenshot 2024-07-04 at 1 04 18 PM

* Checks if a given report action corresponds to a add payment card action.
* @param reportAction
*/
function isActionableAddPaymentCard(reportAction: OnyxEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_ADD_PAYMENT_CARD> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the return type ReportAction here? Shouldn't it be boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rojiphil

We're applying a type predicate - https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates

Not only does this function return a boolean, it also tells the compiler that the argument we passed to it is a specific subtype of ReportAction, which allows us developers to easily access it's properties without the need to do manual assertions.

I hope this answers your requestion 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. That's cool. Thanks.

@rojiphil
Copy link
Contributor

rojiphil commented Jul 4, 2024

@shawnborton Is the gap more than required between the lines Free Trial Expired and Your free trial…? Or Is this intentional?

Screenshot 2024-07-04 at 1 04 02 PM

@shawnborton
Copy link
Contributor

Hmm that doesn't feel intentional. I would think the gap wouldn't be nearly as big.

This is what it currently looks like in the product to have a headline + text below it, assuming all is in the same message:
CleanShot 2024-07-04 at 10 10 25@2x

@rojiphil
Copy link
Contributor

rojiphil commented Jul 4, 2024

@pac-guerreiro Also, please add test steps in the PR description. The prerequisites for the tests are very detailed though. Thanks.

@pac-guerreiro
Copy link
Contributor Author

@rojiphil @shawnborton

There was an additional <br/> tag in the html content of the message which caused the unnecessary space between the headline and the message. I removed it from the PR description to prevent any further mistakes 😄

Screenshot 2024-07-04 at 10 40 16

This is how it looks without the <br/> tag:
Screenshot 2024-07-04 at 10 48 16

Copy link
Contributor

@chiragsalian chiragsalian left a comment

Choose a reason for hiding this comment

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

Code LGTM, just these comments seem to be pending.

…er-expensify-dm-gbr-and-custom-chat-item

# Conflicts:
#	src/components/Icon/Illustrations.ts
@trjExpensify
Copy link
Contributor

Code LGTM, just these #44483 (review) seem to be pending.

Points 1&2 are moot, we don't need to do anything there now as discussed in the thread. @pac-guerreiro did you address point 3?

@pac-guerreiro I think the test steps need to be more elaborative such that QA can test this. Except for the actionable Add Payment Card message tests, can you please add each of the verifiable tests as separate points? Onyx updates can be mentioned as described #44393 (comment)

chiragsalian
chiragsalian previously approved these changes Jul 10, 2024
@chiragsalian
Copy link
Contributor

Point 3 has been addressed. There needs to be some improvements though. I'll post on that shortly. For now there are some merge conflicts to address.

@chiragsalian
Copy link
Contributor

chiragsalian commented Jul 10, 2024

Once you address the conflict feel free to ask on slack for someone else to merge so that it can happen sooner and hence lesser chances of another merge conflict.

Additionally, please make the following changes to your QA steps:

  1. Remove window. from places where you mentioned window.Onyx. The window part is unnecessary.
  2. Replace both instances of mockReportID with 111111, otherwise that could be confusing for a QA tester since they wont know they should replace that. Plus the value of the reportActionID doesn't matter here.
  3. previousReportActionID: lastVisibleAction.reportActionID this will throw error for QA because lastVisibleAction is undefined. Can you test if it works fine with 0 and if so replace with 0. If not you'll need to add steps to get the previous reportActionID. Something i do is open network tab and add an emoji on the previous report ActionID or edit it and see the payload to get its reportActionID.

…er-expensify-dm-gbr-and-custom-chat-item

# Conflicts:
#	src/libs/OptionsListUtils.ts
@pac-guerreiro
Copy link
Contributor Author

@chiragsalian thank you for the help with the QA steps! I applied your suggestions, but let me know if I applied them correctly! Also, I resolved conflicts 😄

mountiny
mountiny previously approved these changes Jul 11, 2024
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Approved with one comment @pac-guerreiro

src/components/LHNOptionsList/OptionRowLHN.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Thanks

@chiragsalian chiragsalian merged commit 075e9fc into Expensify:main Jul 11, 2024
15 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/chiragsalian in version: 9.0.7-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/thienlnam in version: 9.0.7-4 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.7-8 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

function isChatUsedForOnboarding(optionOrReport: OnyxEntry<Report> | OptionData): boolean {
return AccountUtils.isAccountIDOddNumber(currentUserAccountID ?? -1)
? isSystemChat(optionOrReport)
: (optionOrReport as OptionData).isConciergeChat ?? isConciergeChatReport(optionOrReport);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should had used optional chaining here, this caused the app to crash and caused the issue #45492

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.0.8-6 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

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

Successfully merging this pull request may close these issues.