Repository navigation
Description
Problem
When a user has a a Pay-per-use (PPU) plan and has at least 3 purchases (example: 1 billing cycle === 1 purchase), they are unable to delete their workspace. We support this flow in OldDot, but not in NewDot. It leaves the user trapped, unable to delete their workspace and forced to go to OldDot to finish the flow, which hurts our ability to retain customers.
Solution
Implement new RHP UI to support deleting a workspace when user is on PPU plan and has at least 3 purchases.
Flow
User goes to new.expensify.com/settings/workspaces where they have a workspace and clicks "delete workspace"
When the use clicks "delete workspace" we should call a new command called CalculateBillNewDot. This command takes no params other than authToken. This command will return an onyx update for a new onyx key called shouldBillWhenDowngrading. If this key is false then we proceed as normal and we show the confirmation modal that we currently show when deleting a workspace
If shouldBillWhenDowngrading is true then instead of showing the confirmation modal we will open the Pay & Downgrade RHP:
This new UI will be populated by a table displaying the number of current users the workspace has, the discounts available to this user, and their total amount they need to pay before deleting their account. This data will be stored in a new onyx key called billingReceiptDetails. This an example of how that payload will be formed:
{
"subtotal": 0,
"receiptsWithoutDiscount": [
{
"description": "1 Collect user @ $20.00/user",
"amount": 2000,
"formattedAmount": "$20.00",
"type": "",
"percentage": 0
}
],
"discounts": [
{
"description": "0% Annual Subscription Discount (<a href=\"https://www.expensify.com.dev/admin_policies?param={%22section%22:%22group%22}\" style=\"color: #00a5d5;\">Make it 50%</a>)",
"amount": 0,
"formattedAmount": "-$0.00",
"type": "annual",
"percentage": 0
},
{
"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": [],
"billingMonth": "March 2025",
"formattedSubtotal": "$20.00",
"averageYearlyUserPrice": 0,
"monthlyCorpBasePrice": 3600,
"monthlyTeamBasePrice": 2000
}When the user clicks "Pay & downgrade" we should call a new command called PayAndDowngrade. This command also takes no params other than authToken. This command will charge the user and delete their workspace. It can error out in 6 distinct ways. Below is a table outlining the 6 different errors that we know the command can throw and the error messages that will be provided when the command throws.
| Title | Message |
|---|---|
| Insufficient funds | Your card has insufficient funds |
| Purchase type not supported | Your card doesn't support this type of purchase |
| Incorrect Card Number | The card number you entered is incorrect |
| Cannot delete workspace | One of the workspaces you own is set as the Preferred Workspace for a domain group. Please disable the Preferred Workspace setting on the Group Permissions page or transfer the workspace to someone else. |
| Card Declined | Your card was declined |
| Error making payment | There was an error making the payment |
How to test
This issue is is slightly tricky to test because in order for shouldBillWhenDowngrading to be true the user needs to have at least three purchases, but it's not possible to add purchases in staging/production for contributors to test this. So whoever works on this and whoever reviews this will need to use my (@blimpich) ngrok to access my local backend, where they can access a test account that has three purchases on it. Note: my ngrok will only work when I'm online. I generally work Monday-Friday from 9am to 6pm PST. Your work hours will have to at least somewhat overlap mine.
If you're okay with the ngrok and hours overlap situation, update your .env file to look like this
NEW_EXPENSIFY_URL=https:/
NEW_EXPENSIFY_URL=https://new.expensify.com/
SECURE_EXPENSIFY_URL=https://secure.expensify.com.dev/
EXPENSIFY_URL=https://www.expensify.com.dev/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=ac6d22b891daae55283a
SECURE_NGROK_URL=https://secure-expensify-blimpich.ngrok.io/
NGROK_URL=https://expensify-blimpich.ngrok.io/
USE_NGROK=true
USE_WEB_PROXY=false
USE_WDYR=false
CAPTURE_METRICS=false
ONYX_METRICS=false
PUSHER_DEV_SUFFIX=-def525f225124b848df43bee41aa4e7c
Once you have ngrok setup you can access ppu@test.com which should have three valid test purchases, so that you can properly test this. The OTP for logging in will be 000000
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021904213388095519395
- Upwork Job ID: 1904213388095519395
- Last Price Increase: 2025-03-24
Issue Owner
Current Issue Owner: @saklugerMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDONE



Activity
blimpich commentedon Mar 18, 2025
Going to hold this until the backend is ready
[-]Create new "Pay & Downgrade" RHP[/-][+][HOLD] Create new "Pay & Downgrade" RHP[/+]melvin-bot commentedon Mar 21, 2025
Triggered auto assignment to @sakluger (
NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.62 remaining items
jayeshmangwani commentedon Apr 28, 2025
The follow-up issue seems to have been solved from the BE side. One PR was raised by @blimpich . Since I don't have access to that BE PR, could you please link it here?
blimpich commentedon Apr 28, 2025
Yeah we ended deciding to fix the follow up work with a backend change 👍
sakluger commentedon Apr 29, 2025
Okay, so that does that mean this is fixed and ready to pay out?
blimpich commentedon Apr 29, 2025
Yes!
sakluger commentedon Apr 30, 2025
Summarizing payment on this issue:
Contributor: @jayeshmangwani $500, please request on Newdot
Contributor+: @dukenv0307 $500, due via NewDot
jayeshmangwani commentedon Apr 30, 2025
@sakluger, could you please update the summary? I’ll be paid via ND.
garrettmknight commentedon May 2, 2025
$500 approved for @jayeshmangwani
dukenv0307 commentedon May 6, 2025
I also get paid via NewDot, it seems the summary was updated from "please request on Newdot" to "paid via Upwork" by mistake. As @sakluger is OOO, @JmillsExpensify could you help to correct the payment summary when you approve my ND request, thanks 🙏
mallenexpensify commentedon May 8, 2025
Updated comment above
Reopening til @dukenv0307's confirmed they've been paid (or... they requested and are confidently expecting to be paid soon)
Also confirmed they weren't paid via Upwork
dukenv0307 commentedon May 8, 2025
@mallenexpensify Thank you!
@mallenexpensify I've requested so we can close this out now.
JmillsExpensify commentedon May 13, 2025
$500 approved for @dukenv0307