Unable to delete workspace/Workspace shown with Strikethrough font
If you havenโt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.70-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @VictoriaExpensify Slack conversation (hyperlinked to channel name): ts_external_expensify_expense
Action Performed:
- Log into New.Expensify.com with a new email address
- Create a new Workspace to start a subscription
- Go to "subscriptions" and make sure it shows "Annual"
- Go to Workspaces and delete the newly created Workspace
- This will give an error Looks like you're on an annual subscription. Please downgrade your account from your account settings before trying again. and the Workspace will be crossed out (strikethrough)
- Go back to Subscriptions and change from Annual to Pay Per Use
- Go back to Workspaces and attempt to delete - the three dots will be greyed out and it will still be crossed out
Expected Result:
Error message dismissed and user able to delete the workspace
Actual Result:
Error message not dismissed, unable to delete the workspace as its greyed out
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
- [ ] Android: Standalone
- [ ] Android: HybridApp
- [ ] Android: mWeb Chrome
- [ ] iOS: Standalone
- [ ] iOS: HybridApp
- [ ] iOS: mWeb Safari
- [x] MacOS: Chrome / Safari
- [ ] MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/42b17986-89c5-4ce0-ba46-11bbc76377b3
Triggered auto assignment to @greg-schroeder (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
Edited by proposal-police: This proposal was edited at 2024-12-03 03:13:27 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Unable to delete workspace/Workspace shown with Strikethrough font
What is the root cause of that problem?
The current behavior requires dismissing the error message if we want to continue deleting the workspace after it appears. Once the error is dismissed, the action to delete the workspace can proceed as normal.
https://github.com/user-attachments/assets/de493db3-9b76-4f07-af46-173eb9437146
Because calling dismissError will clear the delete workspace error.
https://github.com/Expensify/App/blob/a3fe37d9497119084f18a09b02d1eae9d9dba977/src/pages/workspace/WorkspacesListPage.tsx#L88
https://github.com/Expensify/App/blob/a3fe37d9497119084f18a09b02d1eae9d9dba977/src/pages/workspace/WorkspacesListPage.tsx#L209
After clearing the workspace error, the disable flag will be set to false, and the action to delete the workspace can proceed as normal.
https://github.com/Expensify/App/blob/a3fe37d9497119084f18a09b02d1eae9d9dba977/src/pages/workspace/WorkspacesListPage.tsx#L356
What changes do you think we should make in order to solve the problem?
To resolve this issue, I suggest we should automatically call dismissError when we go back to the workspace list page. Something like that:
const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION);
const isAnnual = privateSubscription?.type === CONST.SUBSCRIPTION.TYPE.ANNUAL;
//src/pages/workspace/WorkspacesListPage.tsx#L370
useEffect(() => {
if (!policies || isAnnual) {
return;
}
const processPolicies = () => {
const policiesList = Object.values(policies)
.filter((policy): policy is PolicyType => PolicyUtils.shouldShowPolicy(policy, isOffline, session?.email))
.map((item) => ({id: item.id, pendingAction: item.pendingAction}));
policiesList.forEach((item) => {
dismissWorkspaceError(item.id, item.pendingAction);
});
};
processPolicies();
// tThis code only executes when going back to the workspace, and to avoid the case where we change `yearly` -> `monthly` -> `yearly`.
}, []);
POC
https://github.com/user-attachments/assets/bdad840a-b91d-4357-bec7-1ad160f74e07
What alternative solutions did you explore? (Optional)
Or if we want to clear the red dot, we can add a dependency to the props before going back, something like that:
const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION);
const isAnnual = privateSubscription?.type === CONST.SUBSCRIPTION.TYPE.ANNUAL;
//src/pages/workspace/WorkspacesListPage.tsx#L370
useEffect(() => {
if (!policies || isAnnual) {
return;
}
const processPolicies = () => {
const policiesList = Object.values(policies)
.filter((policy): policy is PolicyType => PolicyUtils.shouldShowPolicy(policy, isOffline, session?.email))
.map((item) => ({id: item.id, pendingAction: item.pendingAction}));
policiesList.forEach((item) => {
dismissWorkspaceError(item.id, item.pendingAction);
});
};
processPolicies();
}, [isAnnual]);
POC
https://github.com/user-attachments/assets/3872e770-7b4c-43d4-aa01-e711553c064b
Alternative solutions 2:
Or we can call dismissError when we change the subscription.
https://github.com/Expensify/App/blob/ab40264dff9a6c21372617c8744b1013c22dd2d2/src/pages/settings/Subscription/SubscriptionDetails/index.tsx#L47
const onOptionSelected = (option: SubscriptionType) => {
if (privateSubscription?.type === CONST.SUBSCRIPTION.TYPE.ANNUAL && option === CONST.SUBSCRIPTION.TYPE.PAYPERUSE && !account?.canDowngrade) {
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION_SIZE.getRoute(0));
return;
}
if (option === CONST.SUBSCRIPTION.TYPE.PAYPERUSE && policies) {
const policiesList = Object.values(policies)
.filter((policy): policy is PolicyType => PolicyUtils.shouldShowPolicy(policy, isOffline, session?.email))
.map((item) => ({id: item.id, pendingAction: item.pendingAction}));
policiesList.forEach((item) => {
if (item.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
return;
}
Policy.clearDeleteWorkspaceError(item.id);
});
}
Subscription.updateSubscriptionType(option);
};
Note: I've recorded a proof of concept (POC) for each behavior with two solutions. If we need a different behavior, we can continue the discussion in the PR phase
Proposal
Please re-state the problem that we are trying to solve in this issue.
When after changing from Annual to Pay Per Use, error message on workspace settings isn't deleted.
What is the root cause of that problem?
When entering workspace settings, no function activates to dismiss the error message thought we have dismissWorkspaceError function.
https://github.com/Expensify/App/blob/583f777ec579da26bc2e78ca8213df8fcd97f7e4/src/pages/workspace/WorkspacesListPage.tsx#L88-L92
And this part renders error message for delete whenever rendering workspace list and here isn't any function for the issue:
https://github.com/Expensify/App/blob/583f777ec579da26bc2e78ca8213df8fcd97f7e4/src/pages/workspace/WorkspacesListPage.tsx#L320-L356
What changes do you think we should make in order to solve the problem?
We can add a condition to dismiss error message. When the user changed from Annual to Pay Per Use, private subscription is changed. We can add dismissWorkspaceError:
//// add this
const subscription = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION);
//// add this
...
action: () => null,
dismissError: () => null,
isJoinRequestPending: true,
};
}
//// add these
if(policy.errors && policy.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && subscription.at(0).type === CONST.SUBSCRIPTION.TYPE.PAYPERUSE) {
dismissWorkspaceError(policy.id, policy.pendingAction)
}
//// add these
return {
title: policy.name,
icon: policy.avatarURL ? policy.avatarURL : ReportUtils.getDefaultWorkspaceAvatar(policy.name),
action: () => Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policy.id)),
...
Then when there is error for deleting a workspace and when subscription is Pay Per Use, workspace error will be dismissed.
What alternative solutions did you explore? (Optional)
N/A
This is expected we need to first dismiss the error.
@greg-schroeder Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Proposal
Please re-state the problem that we are trying to solve in this issue.
If the workspace deletion failed, the workspace list row stays disabled until we clear the error.
What is the root cause of that problem?
When we delete the workspace, we set the pending action to DELETE. This disables the workspace item. https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/pages/workspace/WorkspacesListPage.tsx#L379
It makes sense to disable it because we already archived all its report, so it doesn't make sense if the user can open the 3-dot menu again to delete it again. The problem here is that, after it fails, the pending action isn't cleared.
What changes do you think we should make in order to solve the problem?
Clears the pending action in failureData.
https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/libs/actions/Policy/Policy.ts#L365-L380
(or finallyData also works)
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can create a test in PolicyTests following the existing test there. The thing that we need to test is that after the request is failed, the policy onyx data pendingAction should be empty.
Job added to Upwork: https://www.upwork.com/jobs/~021865088803803540719
Triggered auto assignment to Contributor-plus team member for initial proposal review - @alitoshmatov (External)
Set External, next up is proposal review
@alitoshmatov will review soon!
@greg-schroeder, @alitoshmatov Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
I am easily able to delete workspace even if subscription is annual. Can we anyone make sure it is still reproducible, if yes I will reassign this issue
I also was able to do it as well just now testing. Huh.
Let's close as not reproducible for now, but please comment/reopen if you disagree
I can still reproduce this. You need to make sure you are deleting the last workspace from the account.
https://github.com/user-attachments/assets/df06c79a-0029-4630-88ae-3d58e558b803
Reopening based on @bernhardoj's last comment
Ah, that makes sense why I couldn't do it. Got it.
Thanks @bernhardoj, I also was able to reproduce it now.
Thank you all for proposals, I think most of the proposals are missing a point that workspace shouldn't be strikethrough, or having delete state in their pending actions. And not dismissing error shouldn't prevent you from interacting with workspace
I think @bernhardoj is the only proposal with correct RCA and provides correct solution. We can go with @bernhardoj 's proposal
C+ reviewed ๐ ๐ ๐
Triggered auto assignment to @srikarparsi, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@greg-schroeder @srikarparsi @alitoshmatov this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
@greg-schroeder, @srikarparsi, @alitoshmatov Eep! 4 days overdue now. Issues have feelings too...
Bump @srikarparsi on contributor assignment :)
Sorry for the delay here, assigning @bernhardoj
PR is ready
cc: @alitoshmatov
Issue not reproducible during KI retests. (First week)
@alitoshmatov is still on the review ... looks like he asked @srikarparsi for help. Do you mind taking a look at the PR and weighing in?
Work continues on linked PR
This issue has not been updated in over 15 days. @greg-schroeder, @srikarparsi, @bernhardoj, @alitoshmatov eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!