Skip to content
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

[$250] Room - Deleted workspace appears in workspace list during room creation flow #53315

Open
8 tasks done
IuliiaHerets opened this issue Nov 29, 2024 · 9 comments
Open
8 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Nov 29, 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.68-2
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  • Account only has one workspace.
  • Invoices feature is enabled.
  1. Go to staging.new.expensify.com
  2. Go to FAB > Send invoice.
  3. Send an invoice to another user.
  4. As invoice receiver, open the invoice room and pay the invoice via Pay with business.
  5. Go back to the invoice sender.
  6. Delete the workspace.
  7. Create a new workspace.
  8. Go to FAB > Start chat > Room.
  9. Click Workspace.
  10. Note that the deleted workspace is still present in the workspace list.
  11. Select the deleted workspace and create a room.

Expected Result:

In Step 10, the deleted workspace should not appear in the workspace list in room creation flow.

Actual Result:

In Step 10, the deleted workspace appears in the workspace list in room creation flow.
When room is created from the deleted workspace, error shows up.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6679809_1732872707026.20241129_171506.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021863656321139042808
  • Upwork Job ID: 1863656321139042808
  • Last Price Increase: 2024-12-02
Issue OwnerCurrent Issue Owner: @rayane-djouah
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 29, 2024
Copy link

melvin-bot bot commented Nov 29, 2024

Triggered auto assignment to @zanyrenney (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.

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Nov 29, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Deleted workspace appears in workspace list during room creation flow

What is the root cause of that problem?

When we try to get active policies we call PolicyUtils.getActivePolicies(policies),

const workspaceOptions = useMemo(
() =>
PolicyUtils.getActivePolicies(policies)

getActivePolicieschecks if!!policy.name && !!policy.id` exists, and returns policies that have !!policy.name && !!policy.id
function getActivePolicies(policies: OnyxCollection<Policy> | null): Policy[] {
return Object.values(policies ?? {}).filter<Policy>(
(policy): policy is Policy => !!policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.name && !!policy.id,

A policy will have name, and id prop when it has an invoice report. Hence workspaceOptions will include the deleted policy

What changes do you think we should make in order to solve the problem?

We should check if policy.type exists too since the prop is available for active workspaces. Or optionally we can use policy.ownerAccountID or policy.role here

...!!policy.name && !!policy.id && !!policy.type

What alternative solutions did you explore? (Optional)

we can use PolicyUtils.shouldShowPolicy to get active policies instead of PolicyUtils.getActivePolicies(policies) as we are doing in WorkspaceListpage

PolicyUtils.shouldShowPolicy(policy, !!isOffline, currentUserLogin)?.filter..

@FitseTLT
Copy link
Contributor

FitseTLT commented Nov 29, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Room - Workspace from the other user appears in workspace list during room creation flow
Note that the deleted workspace is not appearing in the room creation flow you can clearly see from the OP that the workspace appearing in room creation flow is Applause's Workspace 6 while the deleted workspace is Applause's Workspace so the workspace appearing is a workspace from the other user that the current user is not a member.

What is the root cause of that problem?

When a user A has sent an invoice to another user and the other user B paid the invoice but User A deletes this workspace the invoice will be transferred to another workspace of user B where user A is not a member and this workspace where user A is not a member is returned in the policies list from the BE and on room creation flow we are displaying it as we only check for pending delete, policy id and name existence

function getActivePolicies(policies: OnyxCollection<Policy> | null): Policy[] {
return Object.values(policies ?? {}).filter<Policy>(
(policy): policy is Policy => !!policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.name && !!policy.id,
);
}

So when we create a room with it the BE will return an error as the current user is not a member of the workspace
image

What changes do you think we should make in order to solve the problem?

Here

function getActivePolicies(policies: OnyxCollection<Policy> | null): Policy[] {
return Object.values(policies ?? {}).filter<Policy>(
(policy): policy is Policy => !!policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.name && !!policy.id,
);
}

we need to check that the current user is a member of the workspace (by checking the existence of role for the current user) same as we are doing here

function getActivePolicies(policies: OnyxCollection<Policy> | null, currentUserLogin): Policy[] {
    return Object.values(policies ?? {}).filter<Policy>(
        (policy): policy is Policy =>
            !!policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.name && !!policy.id && !!getPolicyRole(policy, currentUserLogin),
    );
}

we can then pass the session?.email as the current user login but even if we don't pass it will check for policy.role which should exist

Note on the above proposal:

  1. the above proposal didn't identify the right problem and RCA
  2. we can use PolicyUtils.shouldShowPolicy to get active policies instead of PolicyUtils.getActivePolicies(policies) as we are doing in WorkspaceListpage

using shouldShowPolicy instead of getActivePolicies will allow pending deletion workspaces when offline to be included in the workspaces list as we normally use shouldShowPolicy to display in workspace list page where we display pending deletion workspaces when offline with strikethrough applied. 👍

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2024
@zanyrenney zanyrenney added the External Added to denote the issue can be worked on by a contributor label Dec 2, 2024
@melvin-bot melvin-bot bot changed the title Room - Deleted workspace appears in workspace list during room creation flow [$250] Room - Deleted workspace appears in workspace list during room creation flow Dec 2, 2024
Copy link

melvin-bot bot commented Dec 2, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 2, 2024
Copy link

melvin-bot bot commented Dec 2, 2024

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

@zanyrenney
Copy link
Contributor

hey there @rayane-djouah please could you review the proposals above if either are suitable?

Thank you!

@etCoderDysto
Copy link
Contributor

A kind reminder.

My proposal already suggests to check for policy.role since active policy will have a value of policy.role = user for a member and policy.role = admin for admin. getPolicyRole checks for policy.role and policy?.employeeList?.[currentUserLogin ?? '-1']?.role which doesn't exist in this case. Therefore there is no upside to using getPolicyRole.

App/src/libs/PolicyUtils.ts

Lines 197 to 199 in 473822d

function getPolicyRole(policy: OnyxInputOrEntry<Policy> | SearchPolicy, currentUserLogin: string | undefined) {
return policy?.role ?? policy?.employeeList?.[currentUserLogin ?? '-1']?.role;
}

The wrong workspace data
Screenshot 2024-12-02 at 10 31 23 at night

Member
Screenshot 2024-12-02 at 10 23 52 at night
Admin
Screenshot 2024-12-02 at 10 22 07 at night

@FitseTLT
Copy link
Contributor

FitseTLT commented Dec 2, 2024

You have identified neither the correct problem nor the correct RCA therefore you haven't backed your solution linking to the correct RCA of the problem. You were just randomly giving several policy props as an option without any logical explanation so it is not acceptable and the reviewer will give the proper review so let's just wait for that.

@etCoderDysto
Copy link
Contributor

No more review seems to needed since you have already done the review on your proposal😆.

the above proposal didn't identify the right problem and RCA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

5 participants