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

Update the free trial badge to display Start a free trial badge when we create a workspace for a user #48512

Merged
merged 25 commits into from
Sep 18, 2024

Conversation

abzokhattab
Copy link
Contributor

@abzokhattab abzokhattab commented Sep 3, 2024

Details

Fixed Issues

$ #48217
PROPOSAL: #48217 (comment)

Tests

  1. Log in with a new account.
  2. Complete the onboarding process using Track and Budget Expenses
  3. In the onboarding Concierge report, validate that the LHN and the header do not display the free trial badge
  4. Create a workspace.
  5. Check the LHN, the report header, and the subscription tab inside the account settings to ensure that all three display the Start your free trial badge.
  6. Submit an expense to the workspace.
  7. Again, check the LHN, the report header, and the subscription tab inside the account settings to ensure that all three display the Free trial: 7 days left badge.

Offline tests

same as tests

QA Steps

same as tests

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
Screen.Recording.2024-09-04.at.12.01.37.AM.mov
Android: mWeb Chrome
Screen.Recording.2024-09-03.at.11.33.53.PM.mov
iOS: Native
Screen.Recording.2024-09-03.at.11.00.03.PM.mov
iOS: mWeb Safari
Screen.Recording.2024-09-03.at.11.01.26.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2024-09-01.at.5.36.34.AM.mov
MacOS: Desktop
Screen.Recording.2024-09-03.at.11.02.38.PM.mov

@abzokhattab abzokhattab requested a review from a team as a code owner September 3, 2024 21:41
@melvin-bot melvin-bot bot requested a review from rojiphil September 3, 2024 21:41
Copy link

melvin-bot bot commented Sep 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]

@melvin-bot melvin-bot bot removed the request for review from a team September 3, 2024 21:41
@rojiphil
Copy link
Contributor

rojiphil commented Sep 4, 2024

@abzokhattab The free trial text is not updated properly as demonstrated in the video below. This is for a case when the trial has expired. Also, the LHN shows Start free trial briefly before transitioning to Your free trial has ended. Can you please check these?
Also, jest unit tests are failing.

20240904_141103.mp4

@anmurali
Copy link

anmurali commented Sep 7, 2024

What is the ETA here? When do we think we will be able to fix the review comments and merge?

@rojiphil
Copy link
Contributor

rojiphil commented Sep 8, 2024

@abzokhattab Please update on the latest status on the comment here.
We need to take this to the finish line sooner as it is already marked as critical.

@abzokhattab
Copy link
Contributor Author

Thanks for your patience, @rojiphil. It took me a bit to find the right solution for the title inconsistency.

I ended up creating a component for the free trial badge and updated getFreeTrialText and related functions to take Onyx data as inputs. The issue was that the free trial text wasn’t updating when the Onyx data changed. By passing the Onyx data directly into the function, it now reacts properly to those changes.

@rojiphil
Copy link
Contributor

rojiphil commented Sep 9, 2024

The review is in progress. I will update today on this.

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.

@abzokhattab Thanks for the changes. I like the component approach here. And I have left few review comments too. Please have a look.

Further, the problem of LHN showing Start a free trial briefly before transitioning to Your free trial has ended is still there as mentioned before here. Can you please check that too? This happens when the user signs in in a free trial or trial ended state. It seems like there is a delay for openApp to update the lastDayFreeTrial and firstDayFreeTrial in Onyx which causes a temporary display of Start a free trial.

src/pages/settings/Subscription/FreeTrailBadge.tsx Outdated Show resolved Hide resolved
const [firstDayFreeTrial] = useOnyx(ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL);
const [lastDayFreeTrial] = useOnyx(ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL);

const freeTrialText = SubscriptionUtils.getFreeTrialText(policies, firstDayFreeTrial, lastDayFreeTrial);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if we use this pattern of passing the Onyx data directly into the function as parameters and, at the same time, initializing the function with the same Onyx data. Instead, would it not be neater to use effect and state to achieve the same as follows?

    const [freeTrialText, setFreeTrialText] = useState<string>();
    useEffect(() => {
        setFreeTrialText(SubscriptionUtils.getFreeTrialText(policies));
    }, [policies, firstDayFreeTrial, lastDayFreeTrial]);  

Copy link
Contributor Author

@abzokhattab abzokhattab Sep 9, 2024

Choose a reason for hiding this comment

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

I was concerned that there might be a delay between the data being updated in useOynx and the data fetched from the global oynx.connect used in the function.
So, I decided to pass it as a function argument, thinking that could be the reason for the delayed transition from 'Start a free trial' to 'Your free trial has ended.'

But I will try this approach.

src/libs/ReportUtils.ts Outdated Show resolved Hide resolved
@rojiphil
Copy link
Contributor

rojiphil commented Sep 9, 2024

Also, Start a free trial message get’s displayed on Concierge chat when it should have been displayed on Expensify system chat on signin. It looks like the delay for openApp to update the onboarding chat id is causing this problem. Here is a test video demonstrating this:

48512-onboardingchatissue.mp4

@abzokhattab
Copy link
Contributor Author

It seems like there is a delay for openApp to update the lastDayFreeTrial and firstDayFreeTrial in Onyx which causes a temporary display of Start a free trial.

do you have a way in mind to address this issue? .. i have tried some approaches but didn't work.

@rojiphil
Copy link
Contributor

rojiphil commented Sep 9, 2024

It seems like there is a delay for openApp to update the lastDayFreeTrial and firstDayFreeTrial in Onyx which causes a temporary display of Start a free trial.

do you have a way in mind to address this issue? .. i have tried some approaches but didn't work.

Hmm.. Interesting scenario here. Maybe BE needs to inform FE via a state like trialState which specifies whether it is preTrial,inTrial, trialEnded or Active. An undefined value can mean noState during which we decide to not show any message.
@chiragsalian What are your thoughts on addressing this issue?

The context here is the problem of LHN showing Start a free trial briefly before transitioning to Your free trial has ended. This is mentioned here and here

@chiragsalian
Copy link
Contributor

Maybe BE needs to inform FE via a state like trialState which specifies whether it is preTrial,inTrial, trialEnded or Active

Its a good idea but generally we should avoid duplicating source of truth unless really necessary. in this scenario its duplicate information because generally freeTrial start and end gives us everything we need. It seems like the catch here is that while the front end is fetching data because the nvp is not set it shows "start a free trial", but once it fetches the nvp it changes the text to "Your free trial has ended", correct?

If that's the case then can we use a flag like isLoading (or nvpsLoading if there isn't an existing one) so that we don't show anything until the NVPs are fetched?

@rojiphil
Copy link
Contributor

while the front end is fetching data because the nvp is not set it shows "start a free trial", but once it fetches the nvp it changes the text to "Your free trial has ended", correct?

That's correct

If that's the case then can we use a flag like isLoading (or nvpsLoading if there isn't an existing one) so that we don't show anything until the NVPs are fetched?

Thanks. That makes sense. @abzokhattab Can you please try this? This would also help us fix this comment

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.

Regarding the blink issue mentioned here, it does not look like an issue to me.

@abzokhattab Please update the test steps 1,2 as follows as Expensify onboarding chat will not be shown anymore:
Step 2: Complete the onboarding process using Track and Budget Expenses
Step 3: In the onboarding Concierge report, validate that the LHN and the header do not display the free trial badge.

Otherwise, LGTM and tests well.
@chiragsalian Over to you for review. Thanks.

@melvin-bot melvin-bot bot requested a review from chiragsalian September 16, 2024 18:23
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.

Nice, great discussions and I like how this PR is shaping up so far. I haven't tested it yet and i'll test/final review it once Roji is done. Oh hah, looks like roji just finished. 👀

Using privateSubscription to determine the NVP is loaded is pretty interesting too.

@abzokhattab
Copy link
Contributor Author

@abzokhattab Please update the test steps 1,2 as follows as Expensify onboarding chat will not be shown anymore:

okay done!

@chiragsalian
Copy link
Contributor

chiragsalian commented Sep 16, 2024

Code, LGTM and it mostly works well but I do see a bug that we should address.
Steps to reproduce:

  1. Log in with a new account.
  2. Select "manage my team" in onboarding. Enter a business name and personal name.
  3. Here the Start a free trial badge shows up which looks good.
  4. Start a DM with some random user and send a message. The idea here is for the newDot focus to be on a new report.
  5. Now signout and signin.
  6. 💥 Start a free trial badge doesn't show up for me
    image
  7. Once i mouse over or click on Concierge then the badge appears, (also clicking on search/settings and going back to chat view shows the badge for me)
    image

Can you guys test the same and confirm the issue.

@abzokhattab
Copy link
Contributor Author

is it occurring on a specific platform?

@chiragsalian
Copy link
Contributor

i only tested on MacOS: Chrome

@chiragsalian
Copy link
Contributor

Any luck on addressing the bug? Were you guys able to reproduce the bug i mentioned @abzokhattab / @rojiphil?

@rojiphil
Copy link
Contributor

@chiragsalian I tried to reproduce just now but I noticed that the focus goes back to the Concierge Chat. Not sure what I am doing wrong. I tried some other things too but I could not get the focus to move away from Concierge chat. Strange but I will try again later. Anyway, here is a video that demonstrates this.
Meanwhile, waiting for @abzokhattab feedback too on this.

48512-hover-issue-1.mp4

@chiragsalian
Copy link
Contributor

Weird yeah, for you it seems to be focused on Concierge when you log in. Im unsure why. For me, actually none of the reports are focused. When i log in i end up with a URL like /r/ without a reportID. I've asked here if its a known bug.

@abzokhattab
Copy link
Contributor Author

abzokhattab commented Sep 18, 2024

I am not able to reproduce it as well .. i couldn't get the focus away from concierge, the only way was by pasting another report URL after logging out so that it redirects to this report after logging in.

however, the main issue is not yet reproducible

let us know if you were able to reproduce it again @chiragsalian

Screen.Recording.2024-09-18.at.1.02.06.PM.mov

@chiragsalian
Copy link
Contributor

Okay i think thats fine. I just checked, on signin, normally we open concierge. I think on my dev something weird was just happening. Okay code here LGTM but you have an eslint failure. Can you update with main and address it so i can merge this PR.

@abzokhattab
Copy link
Contributor Author

Can you update with main and address it so i can merge this PR.

done

@abzokhattab
Copy link
Contributor Author

eslint still complains about this even though the withOynx was not introduced in this PR

image

@chiragsalian
Copy link
Contributor

Ah I see, yeah normally it would be good to address ESLint errors even though it's not related to your code. This way we keep files up to date with our expected styles.
But because you started work well before that change i think its fine to proceed as is.

@chiragsalian chiragsalian merged commit 27ecf63 into Expensify:main Sep 18, 2024
15 of 16 checks passed
@melvin-bot melvin-bot bot added the Emergency label Sep 18, 2024
Copy link

melvin-bot bot commented Sep 18, 2024

@chiragsalian looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@chiragsalian
Copy link
Contributor

Not emergency, only eslint was failing, posted context here.

@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.38-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.0.38-4 🚀

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants