App icon indicating copy to clipboard operation
App copied to clipboard

Unable to delete workspace/Workspace shown with Strikethrough font

Open m-natarajan opened this issue 1 year ago โ€ข 7 comments

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:

  1. Log into New.Expensify.com with a new email address
  2. Create a new Workspace to start a subscription
  3. Go to "subscriptions" and make sure it shows "Annual"
  4. Go to Workspaces and delete the newly created Workspace
  5. 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)
  6. Go back to Subscriptions and change from Annual to Pay Per Use
  7. 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

2024-12-02_16-51-05 (1)

https://github.com/user-attachments/assets/42b17986-89c5-4ce0-ba46-11bbc76377b3

View all open jobs on GitHub

m-natarajan avatar Dec 03 '24 00:12 m-natarajan

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.

melvin-bot[bot] avatar Dec 03 '24 00:12 melvin-bot[bot]

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

huult avatar Dec 03 '24 03:12 huult

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

jacobkim9881 avatar Dec 03 '24 03:12 jacobkim9881

This is expected we need to first dismiss the error.

FitseTLT avatar Dec 03 '24 12:12 FitseTLT

@greg-schroeder Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Dec 06 '24 09:12 melvin-bot[bot]

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.

bernhardoj avatar Dec 06 '24 13:12 bernhardoj

Job added to Upwork: https://www.upwork.com/jobs/~021865088803803540719

melvin-bot[bot] avatar Dec 06 '24 17:12 melvin-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @alitoshmatov (External)

melvin-bot[bot] avatar Dec 06 '24 17:12 melvin-bot[bot]

Set External, next up is proposal review

greg-schroeder avatar Dec 06 '24 17:12 greg-schroeder

@alitoshmatov will review soon!

greg-schroeder avatar Dec 09 '24 10:12 greg-schroeder

@greg-schroeder, @alitoshmatov Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Dec 10 '24 09:12 melvin-bot[bot]

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

alitoshmatov avatar Dec 10 '24 18:12 alitoshmatov

I also was able to do it as well just now testing. Huh.

greg-schroeder avatar Dec 10 '24 19:12 greg-schroeder

Let's close as not reproducible for now, but please comment/reopen if you disagree

greg-schroeder avatar Dec 10 '24 19:12 greg-schroeder

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

bernhardoj avatar Dec 11 '24 08:12 bernhardoj

Reopening based on @bernhardoj's last comment

VictoriaExpensify avatar Dec 11 '24 10:12 VictoriaExpensify

Ah, that makes sense why I couldn't do it. Got it.

greg-schroeder avatar Dec 11 '24 12:12 greg-schroeder

Thanks @bernhardoj, I also was able to reproduce it now.

alitoshmatov avatar Dec 11 '24 18:12 alitoshmatov

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

alitoshmatov avatar Dec 11 '24 18:12 alitoshmatov

I think @bernhardoj is the only proposal with correct RCA and provides correct solution. We can go with @bernhardoj 's proposal

C+ reviewed ๐ŸŽ€ ๐Ÿ‘€ ๐ŸŽ€

alitoshmatov avatar Dec 11 '24 18:12 alitoshmatov

Triggered auto assignment to @srikarparsi, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Dec 11 '24 18:12 melvin-bot[bot]

@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!

melvin-bot[bot] avatar Dec 17 '24 09:12 melvin-bot[bot]

@greg-schroeder, @srikarparsi, @alitoshmatov Eep! 4 days overdue now. Issues have feelings too...

melvin-bot[bot] avatar Dec 17 '24 09:12 melvin-bot[bot]

Bump @srikarparsi on contributor assignment :)

greg-schroeder avatar Dec 17 '24 13:12 greg-schroeder

Sorry for the delay here, assigning @bernhardoj

srikarparsi avatar Dec 17 '24 19:12 srikarparsi

PR is ready

cc: @alitoshmatov

bernhardoj avatar Dec 18 '24 06:12 bernhardoj

Issue not reproducible during KI retests. (First week)

mvtglobally avatar Dec 21 '24 02:12 mvtglobally

@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?

greg-schroeder avatar Jan 06 '25 10:01 greg-schroeder

Work continues on linked PR

greg-schroeder avatar Jan 09 '25 12:01 greg-schroeder

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!

melvin-bot[bot] avatar Jan 10 '25 09:01 melvin-bot[bot]