Skip to content

[C+ Checklist Needs Completion] [$250] Unable to delete workspace/Workspace shown with Strikethrough font #53413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 8 tasks
m-natarajan opened this issue Dec 3, 2024 · 42 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Dec 3, 2024

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
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

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

Recording.814.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021865088803803540719
  • Upwork Job ID: 1865088803803540719
  • Last Price Increase: 2024-12-06
Issue OwnerCurrent Issue Owner: @greg-schroeder
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 3, 2024
Copy link

melvin-bot bot commented Dec 3, 2024

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.

@huult
Copy link
Contributor

huult commented Dec 3, 2024

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.

Screen.Recording.2024-12-03.at.09.55.59.mp4

Because calling dismissError will clear the delete workspace error.

function dismissWorkspaceError(policyID: string, pendingAction: OnyxCommon.PendingAction | undefined) {

onClose={item.dismissError}

After clearing the workspace error, the disable flag will be set to false, and the action to delete the workspace can proceed as normal.

disabled: policy.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,

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
Screen.Recording.2024-12-03.at.10.09.38.mp4

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
Screen.Recording.2024-12-03.at.10.10.23.mp4

Alternative solutions 2:

Or we can call dismissError when we change the subscription.

const onOptionSelected = (option: SubscriptionType) => {

    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

@jacobkim9881
Copy link
Contributor

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.

function dismissWorkspaceError(policyID: string, pendingAction: OnyxCommon.PendingAction | undefined) {
if (pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
Policy.clearDeleteWorkspaceError(policyID);
return;
}

And this part renders error message for delete whenever rendering workspace list and here isn't any function for the issue:

return Object.values(policies)
.filter((policy): policy is PolicyType => PolicyUtils.shouldShowPolicy(policy, isOffline, session?.email))
.map((policy): WorkspaceItem => {
if (policy?.isJoinRequestPending && policy?.policyDetailsForNonMembers) {
const policyInfo = Object.values(policy.policyDetailsForNonMembers).at(0) as PolicyDetailsForNonMembers;
const id = Object.keys(policy.policyDetailsForNonMembers).at(0);
return {
title: policyInfo.name,
icon: policyInfo?.avatar ? policyInfo.avatar : ReportUtils.getDefaultWorkspaceAvatar(policy.name),
disabled: true,
ownerAccountID: policyInfo.ownerAccountID,
type: policyInfo.type,
iconType: policyInfo?.avatar ? CONST.ICON_TYPE_AVATAR : CONST.ICON_TYPE_ICON,
iconFill: theme.textLight,
fallbackIcon: Expensicons.FallbackWorkspaceAvatar,
policyID: id,
role: CONST.POLICY.ROLE.USER,
errors: null,
action: () => null,
dismissError: () => null,
isJoinRequestPending: true,
};
}
return {
title: policy.name,
icon: policy.avatarURL ? policy.avatarURL : ReportUtils.getDefaultWorkspaceAvatar(policy.name),
action: () => Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policy.id)),
brickRoadIndicator: !PolicyUtils.isPolicyAdmin(policy)
? undefined
: reimbursementAccountBrickRoadIndicator ??
PolicyUtils.getPolicyBrickRoadIndicatorStatus(
policy,
isConnectionInProgress(allConnectionSyncProgresses?.[`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy.id}`], policy),
),
pendingAction: policy.pendingAction,
errors: policy.errors,
dismissError: () => dismissWorkspaceError(policy.id, policy.pendingAction),

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

@FitseTLT
Copy link
Contributor

FitseTLT commented Dec 3, 2024

This is expected we need to first dismiss the error.

@garrettmknight garrettmknight moved this to Bugs and Follow Up Issues in #expensify-bugs Dec 3, 2024
@melvin-bot melvin-bot bot added the Overdue label Dec 5, 2024
Copy link

melvin-bot bot commented Dec 6, 2024

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

@bernhardoj
Copy link
Contributor

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.

disabled: policy.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,

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.

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
errors: reimbursementAccount?.errors ?? null,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
avatarURL: policy?.avatarURL,
},
},
];

(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.

@greg-schroeder greg-schroeder added the External Added to denote the issue can be worked on by a contributor label Dec 6, 2024
Copy link

melvin-bot bot commented Dec 6, 2024

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

@melvin-bot melvin-bot bot changed the title Unable to delete workspace/Workspace shown with Strikethrough font [$250] Unable to delete workspace/Workspace shown with Strikethrough font Dec 6, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 6, 2024
Copy link

melvin-bot bot commented Dec 6, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Dec 6, 2024
@greg-schroeder
Copy link
Contributor

Set External, next up is proposal review

@greg-schroeder
Copy link
Contributor

@alitoshmatov will review soon!

@melvin-bot melvin-bot bot added the Overdue label Dec 9, 2024
Copy link

melvin-bot bot commented Dec 10, 2024

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

@alitoshmatov
Copy link
Contributor

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

@melvin-bot melvin-bot bot removed the Overdue label Dec 10, 2024
@greg-schroeder
Copy link
Contributor

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

@greg-schroeder
Copy link
Contributor

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

@github-project-automation github-project-automation bot moved this from Bugs and Follow Up Issues to Done in #expensify-bugs Dec 10, 2024
@bernhardoj
Copy link
Contributor

bernhardoj commented Dec 11, 2024

I can still reproduce this. You need to make sure you are deleting the last workspace from the account.

a.mp4

@bernhardoj
Copy link
Contributor

PR is ready

cc: @alitoshmatov

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@greg-schroeder
Copy link
Contributor

@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
Copy link
Contributor

Work continues on linked PR

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Jan 10, 2025
Copy link

melvin-bot bot commented Jan 10, 2025

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!

@greg-schroeder
Copy link
Contributor

@alitoshmatov I think you're next up on the linked PR as I see you requested for review

@greg-schroeder greg-schroeder added Daily KSv2 and removed Monthly KSv2 labels Jan 16, 2025
Copy link

melvin-bot bot commented Jan 24, 2025

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

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jan 28, 2025
@melvin-bot melvin-bot bot changed the title [$250] Unable to delete workspace/Workspace shown with Strikethrough font [HOLD for payment 2025-02-04] [$250] Unable to delete workspace/Workspace shown with Strikethrough font Jan 28, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 28, 2025
Copy link

melvin-bot bot commented Jan 28, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jan 28, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.89-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-02-04. 🎊

For reference, here are some details about the assignees on this issue:

  • @bernhardoj requires payment through NewDot Manual Requests
  • @alitoshmatov requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Jan 28, 2025

@alitoshmatov @greg-schroeder @alitoshmatov The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 3, 2025
Copy link

melvin-bot bot commented Feb 4, 2025

Payment Summary

Upwork Job

BugZero Checklist (@greg-schroeder)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1865088803803540719/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@greg-schroeder
Copy link
Contributor

Bump @alitoshmatov on the checklist! Then we can close.

@greg-schroeder greg-schroeder changed the title [HOLD for payment 2025-02-04] [$250] Unable to delete workspace/Workspace shown with Strikethrough font [C+ Checklist Needs Completion] [$250] Unable to delete workspace/Workspace shown with Strikethrough font Feb 5, 2025
@alitoshmatov
Copy link
Contributor

alitoshmatov commented Feb 5, 2025

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    Link to comment: Couldn't pinpoint exact PR, the pending action delete was added in this PR. My guess is strikethrough was not introduce at that time and it was working fine. After strikethrough (and other styles for delete action) was introduced in OfflineWithFeedback component the issue started appearing.

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

    Link to discussion: https://expensify.slack.com/archives/C01GTK53T8Q/p1734645393299519

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

No regression needed. Reproducing original issue is also hard since the error condition required for reproduction is not present now

@greg-schroeder
Copy link
Contributor

Thanks @alitoshmatov!

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

@JmillsExpensify
Copy link

$250 approved for @alitoshmatov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests