App
App copied to clipboard
[HOLD #44691] WS plan type and upgrade common features view Pages
Explanation of Change
Fixed Issues
$ https://github.com/Expensify/App/issues/51768 PROPOSAL:
Tests
- Go to Workspaces -> Workspace -> Profile.
- If the user has admin access, they will see the Plan Type tab under the Company address menu item.
- Click on Plan Type to open a new RHP screen for Plan Type, where the current workspace plan will be preselected.
- [x] Verify that no errors appear in the JS console
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
- [x] Verify that no errors appear in the JS console
PR Author Checklist
- [x] I linked the correct issue in the
### Fixed Issuessection above - [x] I wrote clear testing steps that cover the changes made in this PR
- [x] I added steps for local testing in the
Testssection - [x] I added steps for the expected offline behavior in the
Offline stepssection - [x] I added steps for Staging and/or Production testing in the
QA stepssection - [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- [x] 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)
- [x] 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).
- [x] I added steps for local testing in the
- [x] I included screenshots or videos for tests on all platforms
- [x] I ran the tests on all platforms & verified they passed on:
- [x] Android: Native
- [x] Android: mWeb Chrome
- [x] iOS: Native
- [x] iOS: mWeb Safari
- [x] MacOS: Chrome / Safari
- [x] MacOS: Desktop
- [x] 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)
- [x] I followed proper code patterns (see Reviewing the code)
- [x] 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.
toggleReportand notonIconClick) - [x] I verified that comments were added to code that is not self explanatory
- [x] 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.
- [x] I verified any copy / text shown in the product is localized by adding it to
src/languages/*files and using the translation method- [x] 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:
- [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
- [x] 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)
- [x] 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.
- [x] I verified the JSDocs style guidelines (in
STYLE.md) were followed
- [x] 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.
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I followed the guidelines as stated in the Review Guidelines
- [x] 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 usingAvatarare working as expected) - [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- [x] 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
- [x] I verified that if a function's arguments changed that all usages have also been updated correctly
- [x] If any new file was added I verified that:
- [x] 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
- [x] If a new CSS style is added I verified that:
- [x] A similar style doesn't already exist
- [x] The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
- [x] 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.
- [x] 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
Avataris modified, I verified thatAvataris working as expected in all cases) - [x] 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.
- [x] 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.
- [x] 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:
- [x] I verified that all the inputs inside a form are aligned with each other.
- [x] I added
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- [x] If a new page is added, I verified it's using the
ScrollViewcomponent to make it scrollable when more elements are added to the page. - [x] If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.
Screenshots/Videos
Android: Native
https://github.com/user-attachments/assets/670f30b6-10ec-4aa8-9073-703b02665008
Android: mWeb Chrome
https://github.com/user-attachments/assets/b474a0a7-e58f-4ff2-94b1-7d2b12d8b81d
iOS: Native
https://github.com/user-attachments/assets/0a093048-18c7-458a-9590-5cabf5192b0b
iOS: mWeb Safari
https://github.com/user-attachments/assets/a1e67340-cd74-4d85-a307-f52c0b984a46
MacOS: Chrome / Safari
https://github.com/user-attachments/assets/cafeda4a-427d-47ed-8a16-977254be125a
MacOS: Desktop
https://github.com/user-attachments/assets/aa13bbc3-c7f9-4d37-82d3-e17e9f797bfc
@jayeshmangwani @carlosmiceli How can we handle this PR to get it merged? Should we create a flag to hide this feature and only display these pages when all done
Should we create a flag to hide this feature and only display these pages when all done
Yes, that sounds correct to me. We can either hide this feature by hardcoding it OR Do not merge this PR until our downgrade logic is implemented. In that case, you would need to create a new branch from this PR to reuse the WS plan type page.
Hi @carlosmiceli , Following this discussion https://expensify.slack.com/archives/C02NK2DQWUX/p1731682677445059 , we concluded that we will display the locked plan UI only if the user has an annual control plan and their first billing is completed. I'll need your help to determine from the backend whether the first billing has been completed for the user.
Which parameter would be best to use to get this status? I noticed the retry_billing_success NVP, but I wanted to confirm if this can be used for this purpose or if there's another NVP that would be more suitable.
Gotcha! Let me find that for you and report back.
@carlosmiceli we also need to confirm the next step on this problem
Yes, that sounds correct to me. We can either hide this feature by hardcoding it
this option looks fine to me because of simpleness
this option looks fine to me because of simpleness
Sounds good, once it's all ready to be tested in dev we can change the hardcoded code. Let's make sure to add a comment where we do it.
Great @carlosmiceli @DylanDylann! I've added a function to hide the plan type button. We'll enable it for testing, and once the downgrade API is implemented and tested, we'll remove this function altogether and display the button.
@jayeshmangwani it's looking like this will need a BE change, and we can send a firstBilling bool to show/hide the UI. Which API's response would we need to modify?
@jayeshmangwani bump ☝️
@carlosmiceli I'm not entirely sure, but in my opinion, we may need to create a new command for this. The command would return the firstBilling value under the nvp_private_subscription key, similar to how we've implemented the OpenSubscriptionPage. What do you think about creating a new command, OpenWorkspacePlanPage, which would return the current nvp_private_subscription value with the new firstBilling key included?
@jayeshmangwani I like that idea, just asked in Slack for some feedback in case there's some risk I'm not seeing, will report back.
@jayeshmangwani a couple of questions to confirm, I'm building the new command:
- Is
firstBillinga date, or is it abooland it should be called something likeisFirstBillingComplete? - You don't need the placeholder values for this text to come back in the response, right? How are we getting those values?
@carlosmiceli
- Yes, it should be a boolean value, and
isFirstBillingCompletewill work. - Currently, we are retrieving the
endDatevalue from thenvp_private_subscriptionkey. This data is provided by theReconnectAppandOpenAppAPIs, and it is also updated via theOpenSubscriptionPagecommand.
I’m attaching the responses below from the ReconnectApp and OpenSubscriptionPage for the nvp_private_subscription key.
ReconnectApp Response
{
"key": "nvp_private_subscription",
"onyxMethod": "merge",
"value": {
"autoRenew": true,
"autoRenewLastChangedDate": "2024-12-04 06:41:53",
"endDate": "2025-12-01",
"startDate": "2024-12-01",
"type": "yearly2018"
}
},
OpenSubscriptionPage Response
{
"accountID": 12685249,
"authToken": "659A2AF019C7E6EDCF97155BDBA5FD7B64C7065A4FF42E993A3DE454E16BF899E0E39ABA9D72BA0B31DC0677DE570A580C20F31F915E62F5DEE7131EAF29075741EAD2A2D3518AD76C63F30FD1B8B0AB15BD4ACABDE076DB3C9BB91EAED7A4C84AFDBA2261E80EBB663803BAC09D0B0E515C94FD4ADE2310F3752232BDA5C62B35169405D888CB15ACBB9E707B063CA69D4AC3F8558F9F9CBB2913628A59A9128E51E4E498D2A930FB0AFAECA5F5BB2E24A2DCE238AC0A9FF305D701F93BF37A0C9A0CE54E9887EAE296B65F9608012A66AABF993433A38F28EB2FC7CB74273845251C601D4EE7F16E54A28698FDF6AEAE03B14D1A972506D7DF224FF000C7D07EA6F3799373A991B6D794AD3136B43BD1ED6E1CF154B3E2AF16E4951BA0F6892A3886697C5B89684124112C3E8D5E5347AB683EF5501A9C9F3BB6626DFDE1858E4115C5F1A2349292CF6E175C920546304530AC4F0FE85E6108CF440A87F862",
"email": "[email protected]",
"onyxData": [
{
"key": "nvp_private_subscription",
"onyxMethod": "merge",
"value": {
"autoRenew": true,
"autoRenewLastChangedDate": "2024-12-04 06:41:53",
"endDate": "2025-12-01",
"startDate": "2024-12-01",
"type": "yearly2018"
}
},
{
"key": "nvp_private_amountOwed",
"onyxMethod": "merge",
"value": 2000
},
{
"key": "nvp_private_stripeCustomerID",
"onyxMethod": "merge",
"value": null
},
{
"key": "nvp_private_billingDisputePending",
"onyxMethod": "merge",
"value": null
},
{
"key": "nvp_private_billingStatus",
"onyxMethod": "merge",
"value": {
"action": "failed",
"periodMonth": 10,
"periodYear": 2024
}
},
{
"key": "nvp_private_billingGracePeriodEnd",
"onyxMethod": "merge",
"value": 1730903003
},
{
"key": "nvp_private_disableAutoRenewReasons",
"onyxMethod": "merge",
"value": null
},
{
"key": "nvp_private_cancellationDetails",
"onyxMethod": "merge",
"value": null
},
{
"key": "account",
"onyxMethod": "merge",
"value": {
"canDowngrade": true,
"hasPurchases": true,
"isApprovedAccountant": false,
"isApprovedAccountantClient": false,
"isEligibleForRefund": false
}
},
{
"key": "fundList",
"onyxMethod": "merge",
"value": {}
}
],
"httpCode": 200,
"jsonCode": 200,
"authResponseMessage": "200 OK",
"requestID": "8eea18b36e7f3b8b-BOM"
}
@jayeshmangwani both BE PRs are now in review, but here's how it works so you can make the changes to this and other PRs that need this command:
- The command name is
OpenWorkspacePlanPage. - You'll need to send the
policyIDso we can confirm the user is admin. - The response will include a
canDowngradekey instead offirstBilling.
Sounds good! I'll make the changes locally and test once OpenWorkspacePlanPage will live on staging
@jayeshmangwani the BE is being merged as we speak, can we confirm that we're adding proper QA steps for this? Remember that canDowngrade is a bool.
can we confirm that we're adding proper QA steps for https://github.com/Expensify/App/pull/53343#issuecomment-2530425584?
@carlosmiceli I need to update the QA steps as its not cover the locked type scenario in the existing QA steps but I'll update steps.
Additionally, I am trying to call the OpenWorkspacePlanPage command on staging but am getting a 404 Not Found error. It seems like the command is not yet available on staging
@jayeshmangwani try now, just merged the other PR :)
@carlosmiceli I have tried, but I am still getting a 404 error. I am adding the cURL command below; please let me know if there is anything wrong with the parameters I am passing
OpenWorkspacePlanPage cURL
curl 'https://dev.new.expensify.com:8082/staging/api/OpenWorkspacePlanPage?' \
-H 'Accept: */*' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryhD8BaWyWoQPtBact' \
-H 'Origin: https://dev.new.expensify.com:8082' \
-H 'Referer: https://dev.new.expensify.com:8082/settings/workspaces/5E6D21E477EA2384/profile/plan' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw $'------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="policyID"\r\n\r\n5E6D21E477EA2384\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="apiRequestType"\r\n\r\nread\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="authToken"\r\n\r\n004926853C82257D4E1F329BA81544374B4803204A1E59B4921163C132DE905826021CA58AC33F434E8FAB537B3BE20B9AEF13845AC9781305155EE23EBDA8ABE607FB2F37C571609020AB8B0F246B0B301EC1A107A2102EE9157D66A5D238BFB7CBF80139507672CD2D039A760BBB1863FED1243B77653274C7CC95D7281953E96D50F211A9483239B6E550A7FCA3657B8166A88A4F66451818CCC6F64FE598AE7CD4C905F8A8371F713AB95F9D6287AE7F1A44275D9987419D85F400C683B0BD7B1056C3A7879BC2BE6AFD52C55DA52803F2C845025AB2289CAEB50581EE7261AA1861EFF8B1FF1CD72232BE562A1F680F883F7FC5DB05F780DCD9DBFBF1240D29037D689FAA3816D902643EC1686C2D600BF29E247C4FEE67AA49CDA80C364C47DFEB7DAB972822CE0CA05DAE58AD0A753C50ED6AA88E8F62CB27873F53FB4DBDB3F70706BABA161CAA5EB12244C467B2C1FDA100000653A9BFF8F3DDFEBF\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="referer"\r\n\r\necash\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="platform"\r\n\r\nweb\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="api_setCookie"\r\n\r\nfalse\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="email"\r\n\r\[email protected]\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="isFromDevEnv"\r\n\r\ntrue\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="appversion"\r\n\r\n9.0.74-4\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact\r\nContent-Disposition: form-data; name="clientUpdateID"\r\n\r\n3364146410\r\n------WebKitFormBoundaryhD8BaWyWoQPtBact--\r\n'
Are you getting 404 specifically? Can you share the full response?
Also, not sure how this works yet between App and the BE, but isn't it supposed to be a Get method?
@jayeshmangwani BE fixes were merged, you were right that there was a wrong response being sent. Can you try again and let me know?
Thank you @carlosmiceli for making the BE changes. I have tested them, and now I am able to get a success response that includes the canDowngrade value.
@jayeshmangwani Is this ready for review?
@DylanDylann , the new OpenWorkspacePlanPage command hasn’t been added to this PR yet, but I think I can raise a follow-up PR for that new command. For now, we can merge this PR to unblock the other issue: https://github.com/Expensify/App/issues/51515.
I’m currently resolving conflicts, and then we can merge this PR so Dylan can proceed with their PR. What do you think about this plan, @carlosmiceli ?
@DylanDylann, please review this PR. It includes the following changes:
- If the user has admin rights, they will now see a new row in the workspace profile for "Plan Type."
- If the user is on the "Collect" plan and selects the "Control" row, they can successfully upgrade their workspace plan.
Note that we haven’t added a new command to determine the locked plan type in this PR. I plan to follow up with that in a separate PR to make it easier to review and test individually.
@DylanDylann, I need your help with handling the OpenWorkspacePlanPage response, as it’s a bit different from common API responses.
This command returns a canDowngrade value, which will allow us to show two different views:
- "Workspace Plan Type Selection" if the value is true, and
- "Locked Type" if it’s false.
The issue is that when we call this API, we don’t get onyxData. Instead, we receive the canDowngrade value. I’m attaching the response below for reference.
OpenWorkspacePlanPage Response
{
"accountID": 14498066,
"authToken": "0B04EE0333A9DB8FCFCDE9EC09CC5A95A19206F4735BBE6326B020D764F54B126D5AFF4E823EC91B3169917E0B8F38AEE6FB861D6B2560124080AE754377E2C23B07A3106DB2C0C641CF685636A70FA5B02DC57AECDFC30A2ACB9C0168E8D64B8BD4E9C6F070652CB3835FC8AF0D148A7B30D6C569E63280CD79C9E045D213FB4E0FF105AA0338287BA9E6AA6E2559C5DF5764DAA361849BC0E353751029F4EB7A83CCEEDBDF461D185FF9C28AFBA51C12C77C130AC130F013F194477B23B2F046B0744A8D5A19180E3F3B0E996CE04899693E995C9ACD07FAB147A36D052575FFB4E0ACE8DE0248E2B3A80A471582A4A68B69C089F4E17A04259A5861C1D260D543A04C1F4970B94FFDAF15BC3BCED911B555A74EB9556655DC325482DE9326E68487439CFD6A4492F75324D1EFF0AAA3152809E9AAAAB6D1C1B78EE5460C9D06FF1BFC03D79B9EC68C276BA8D47F8B372D0BA4AC1A0D6564A",
"canDowngrade": true,
"email": "[email protected]",
"httpCode": 200,
"jsonCode": 200,
"authResponseMessage": "200 OK",
"requestID": "8f142b5b4ff34907-BOM",
"onyxData": []
}
Here are my questions:
- In your opinion, how should we add this new key?
- What view should we show if the API call fails?
- What view should we show when the user is offline?
- What should we display while the API is still loading?
Here’s what I’m thinking about how we can handle this. Let me know your thoughts:
- New Onyx Key: We can add a new Onyx key specifically for this page. It will include two properties:
- isLoading
- canDowngrade
-
API Failure Handling: Not completely sure about the best approach for this. Suggestions welcome!
-
Offline Handling: We can disable this page when offline and show a full-screen offline view, we already disabled the button on next page when offline.
-
Loading State: A full-screen loader while the API call is in progress.
Should we update the BE to return?
"onyxData": [
{
"key": "policy_3BA0B3668E73258D",
"onyxMethod": "merge",
"value": {
"canDowngrade": true,
}
]