Skip to content

create pay and downgrade rhp#59070

Merged
blimpich merged 18 commits intoExpensify:mainfrom
dukenv0307:feat/58603
Apr 16, 2025
Merged

create pay and downgrade rhp#59070
blimpich merged 18 commits intoExpensify:mainfrom
dukenv0307:feat/58603

Conversation

@dukenv0307
Copy link
Copy Markdown
Contributor

@dukenv0307 dukenv0307 commented Mar 25, 2025

Explanation of Change

Fixed Issues

$ #58603
PROPOSAL:

Tests

  1. Login to an account that has only 1 paid workspace and has at least 3 purchases (example: 1 billing cycle === 1 purchase)
  2. Go to Workspace list page
  3. Click the three dot icon
  4. Delete workspace
  5. Verify that: The Pay & downgrade page is shown
  6. Click Pay & downgrade button
  7. If success: The RHP will close and WS is deleted
  8. If failed: The error message will be shown
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Same as above

  • 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
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it 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.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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@dukenv0307 dukenv0307 marked this pull request as ready for review March 25, 2025 14:42
@dukenv0307 dukenv0307 requested a review from a team as a code owner March 25, 2025 14:42
@melvin-bot melvin-bot bot requested review from jayeshmangwani and removed request for a team March 25, 2025 14:42
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Mar 25, 2025

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

@jayeshmangwani
Copy link
Copy Markdown
Contributor

Thanks for the PR @dukenv0307 and If you can add the Tests to the PR description, that would be helpful. Also, I just want to confirm—do we need to wait for testing until @blimpich comes online? Their ngrok setup might not be working right now, but I’m not entirely sure.

@blimpich
Copy link
Copy Markdown
Contributor

@jayeshmangwani yeah the ngrok setup doesn't work unless I'm online sadly. Let me know if that doesn't work with your schedule and we can find another C+ 👍

@dukenv0307
Copy link
Copy Markdown
Contributor Author

@jayeshmangwani I updated the steps. Can you please test it? Thanks

@jayeshmangwani
Copy link
Copy Markdown
Contributor

@jayeshmangwani yeah the ngrok setup doesn't work unless I'm online sadly. Let me know if that doesn't work with your schedule and we can find another C+ 👍

@blimpich I’m fine with the schedule and will be online during this timeline. I’m starting the review now.

discounts: BillingItem[];

/** A list of sales tax items */
salesTax: BillingItem[];
Copy link
Copy Markdown
Contributor

@jayeshmangwani jayeshmangwani Mar 26, 2025

Choose a reason for hiding this comment

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

The salesTax value from billingDetails is currently an object, also pressing 'Delete' from the overview causes the app to crash.

{
    "description": "Sales Tax ( - 0%)",
    "amount": 104,
    "formattedAmount": "$1.04",
    "type": "",
    "percentage": 0
}

@jayeshmangwani
Copy link
Copy Markdown
Contributor

@dukenv0307 Pressing 'Delete' causes the app to crash

crash-on-delete.mov

@dukenv0307
Copy link
Copy Markdown
Contributor Author

@jayeshmangwani That's weird. Based on the data mentioned here, the salesTax should be an array, and when I use staging server, it's also an array cc @blimpich

@jayeshmangwani
Copy link
Copy Markdown
Contributor

Then , there might be a backend issue. I’m currently testing the pay-and-downgrade page directly. @blimpich can check this API response later

Just a note—I’m testing this with the ngrok .env, in case it helps with debugging the issue.

const [shouldBillWhenDowngrading] = useOnyx(ONYXKEYS.SHOULD_BILL_WHEN_DOWNGRADING);
const isDeletingPaidWorkspaceRef = useRef(false);

const setIsDelingPaidWorkspace = (value: boolean) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo

@blimpich
Copy link
Copy Markdown
Contributor

Strange, I'm pretty sure I copied that example of billingReceiptData straight from the dev tools so it should've been an object, but for some reason it wasn't. It should be an object, not an array. Here is another example of billingReceiptDetails, but this time with a populated salesTax entry:

{
    "subtotal": 0,
    "receiptsWithoutDiscount": [
        {
            "description": "1 Collect user @ $20.00/user (1 committed)",
            "amount": 2000,
            "formattedAmount": "$20.00",
            "type": "",
            "percentage": 0
        }
    ],
    "discounts": [
        {
            "description": "50% Annual Subscription Discount ",
            "amount": 1000,
            "formattedAmount": "-$10.00",
            "type": "annual",
            "percentage": 50
        },
        {
            "description": "0% Expensify Card Discount (<a href=\"https://www.expensify.com.dev/inbox?taskID=AddWithdrawalAccount\" style=\"color: #00a5d5;\">Make it 25%</a>)",
            "amount": 0,
            "formattedAmount": "-$0.00",
            "type": "expensifyCard",
            "percentage": 0
        }
    ],
    "salesTax": {
        "description": "Sales Tax ( - 0%)",
        "amount": 104,
        "formattedAmount": "$1.04",
        "type": "",
        "percentage": 0
    },
    "billingMonth": "February 2025",
    "formattedSubtotal": "$10.00",
    "averageYearlyUserPrice": 1000,
    "monthlyCorpBasePrice": 3600,
    "monthlyTeamBasePrice": 2000
}

@dukenv0307
Copy link
Copy Markdown
Contributor Author

@jayeshmangwani Can you please check again? BTW, I'm asking for the translation here: https://expensify.slack.com/archives/C01GTK53T8Q/p1743100833103959

@jayeshmangwani
Copy link
Copy Markdown
Contributor

Thanks, Checking in 30 minutes.

@jayeshmangwani
Copy link
Copy Markdown
Contributor

jayeshmangwani commented Mar 27, 2025

@dukenv0307, can you please confirm on your side if the changes work well on Safari and mWeb Safari? I’m not sure why, but the shouldCalculateBillNewDot value shows as false on Safari while it works fine on Chrome.

safari.-shouldCalculateBillNewDot.mov

@jayeshmangwani
Copy link
Copy Markdown
Contributor

Not a major issue, but upon refreshing, Not Found page briefly appears. We could add a loader while the data loads.

on-refresh-bug.mov

@jayeshmangwani
Copy link
Copy Markdown
Contributor

@blimpich @dukenv0307, what do you think about adding a visual loader or some kind of representation to indicate that we’re waiting for the CalculateBillNewDot API response? Currently, pressing delete doesn’t do anything for about 2 seconds until the API responds.

no-visual-apear.mov

@shawnborton shawnborton requested a review from a team March 27, 2025 21:08
@blimpich
Copy link
Copy Markdown
Contributor

blimpich commented Mar 27, 2025

Yeah we should have some form of loading indicator, good point! I talked with design about this, we want the menu item popover to stay open after you click "delete" and for the trash can icon to change to a loading spinner while we wait for shouldBillWhenDowngrading to be returned from CalculateBillNewDot.

@shawnborton
Copy link
Copy Markdown
Contributor

And echoing that point, for the Delete button from the Workspace Overview, let's use our loading spinner pattern on the button after you press delete.

@jayeshmangwani
Copy link
Copy Markdown
Contributor

Thankyou! Let's go ahead with these ideas #59070 (comment) And #59070 (comment)

@dannymcclain
Copy link
Copy Markdown
Contributor

Big agree! Those will be great improvements here.

@dubielzyk-expensify
Copy link
Copy Markdown
Contributor

Agree with Shawn about the spinner 👍

@dukenv0307
Copy link
Copy Markdown
Contributor Author

@jayeshmangwani I updated the PR

@jayeshmangwani
Copy link
Copy Markdown
Contributor

@dukenv0307 have you tested this PR on safari and mobile?

@dukenv0307
Copy link
Copy Markdown
Contributor Author

@jayeshmangwani It works well on my side. Did you use the same account as Chrome?

Screen.Recording.2025-03-31.at.00.02.50.mov

Copy link
Copy Markdown
Contributor

@jayeshmangwani jayeshmangwani left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@melvin-bot melvin-bot bot requested a review from blimpich April 14, 2025 13:48
@dukenv0307
Copy link
Copy Markdown
Contributor Author

@jayeshmangwani I resolved all your comments above

Screen.Recording.2025-04-14.at.21.36.11.mov

@jayeshmangwani
Copy link
Copy Markdown
Contributor

Thank you for making the changes! @blimpich All yours.

@blimpich
Copy link
Copy Markdown
Contributor

Will review sometime today, nice work 👍

Copy link
Copy Markdown
Contributor

@blimpich blimpich left a comment

Choose a reason for hiding this comment

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

Looks very good overall. Couple minor comments. Once those are resolved I think we're good to merge 👍

@dukenv0307
Copy link
Copy Markdown
Contributor Author

@blimpich Thanks for your suggestions. I reoslved all of them

Copy link
Copy Markdown
Contributor

@blimpich blimpich left a comment

Choose a reason for hiding this comment

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

LGTM, lets merge!

@blimpich blimpich merged commit 17704a9 into Expensify:main Apr 16, 2025
16 checks passed
@OSBotify
Copy link
Copy Markdown
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.

@blimpich
Copy link
Copy Markdown
Contributor

Note to QA: this probably can't be QA'ed since it requires having an account with at least 3 purchases. I don't think this is possible to test in QA.

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/blimpich in version: 9.1.29-0 🚀

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

@kavimuru
Copy link
Copy Markdown

@dukenv0307 @blimpich Our QA team does not have an account with this condition:

Login to an account that has only 1 paid workspace and has at least 3 purchases (example: 1 billing cycle === 1 purchase)

Could this be verified internally?

@blimpich
Copy link
Copy Markdown
Contributor

On staging, not really. This is unfortunately very difficult to test. So lets just skip QA for now. We'll deal with issues with this as they come up 👍

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 9.1.29-10 🚀

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

}

if (!shouldBillWhenDowngrading) {
setIsDeleteModalOpen(true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line created a bug. More details - #61040

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.

9 participants