App icon indicating copy to clipboard operation
App copied to clipboard

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

Open IuliiaHerets opened this issue 1 year ago β€’ 19 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.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:

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

Screenshots/Videos

https://github.com/user-attachments/assets/41345c31-7407-444b-ab51-3a57231d685b

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
  • Automatic offers:
    • shubham1206agra | Contributor | 105188027
    • FitseTLT | Contributor | 105188077
Issue OwnerCurrent Issue Owner: @FitseTLT

IuliiaHerets avatar Nov 29 '24 11:11 IuliiaHerets

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.

melvin-bot[bot] avatar Nov 29 '24 11:11 melvin-bot[bot]

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), https://github.com/Expensify/App/blob/2e8892795b844b960d692116b8153e1945964d71/src/pages/workspace/WorkspaceNewRoomPage.tsx#L63-L65 getActivePolicieschecks if!!policy.name && !!policy.id` exists, and returns policies that have !!policy.name && !!policy.id https://github.com/Expensify/App/blob/2e8892795b844b960d692116b8153e1945964d71/src/libs/PolicyUtils.ts#L74-L76

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

etCoderDysto avatar Nov 29 '24 11:11 etCoderDysto

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 https://github.com/Expensify/App/blob/64eaf2fdd357bd06008adfb9c0c049e09cd375b9/src/libs/PolicyUtils.ts#L74-L78 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 https://github.com/Expensify/App/blob/64eaf2fdd357bd06008adfb9c0c049e09cd375b9/src/libs/PolicyUtils.ts#L74-L78 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)

FitseTLT avatar Nov 29 '24 13:11 FitseTLT

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

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

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

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

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

Thank you!

zanyrenney avatar Dec 02 '24 18:12 zanyrenney

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.

https://github.com/Expensify/App/blob/473822dd22944b9d16053376aadd627d882954e5/src/libs/PolicyUtils.ts#L197-L199

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

etCoderDysto avatar Dec 02 '24 19:12 etCoderDysto

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.

FitseTLT avatar Dec 02 '24 19:12 FitseTLT

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

etCoderDysto avatar Dec 02 '24 19:12 etCoderDysto

Commenting here as per slack convo

shubham1206agra avatar Dec 04 '24 10:12 shubham1206agra

Assigning @shubham1206agra as the C+ since @rayane-djouah hasn't reviewed the proposals yet. We chatted here about the issue.

cristipaval avatar Dec 04 '24 10:12 cristipaval

I have discussed this with @cristipaval about this. And we have decided to assign @etCoderDysto's proposal.

πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

shubham1206agra avatar Dec 04 '24 10:12 shubham1206agra

Current assignee @cristipaval is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

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

@FitseTLT and @etCoderDysto Fair warning to both of you. Be civil in the discussion. Otherwise, it will result in permanent ban from here.

shubham1206agra avatar Dec 04 '24 10:12 shubham1206agra

ah, no, sorry, my bad in that Slack channel. I wanted to actually point to @FitseTLT proposal.

cristipaval avatar Dec 04 '24 10:12 cristipaval

@cristipaval You can assign @FitseTLT then.

shubham1206agra avatar Dec 04 '24 10:12 shubham1206agra

πŸ“£ @FitseTLT πŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

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

@FitseTLT and @etCoderDysto Fair warning to both of you. Be civil in the discussion. Otherwise, it will result in permanent ban from here.

yes, no πŸ‘Ž and no attacks on other's proposals, please.

cristipaval avatar Dec 04 '24 10:12 cristipaval

Fair warning to both of you. Be civil in the discussion. Otherwise, it will result in permanent ban from here.

yes, no πŸ‘Ž and no attacks on other's proposals, please.

@shubham1206agra @cristipaval Sorry, I will keep things civil πŸ™‡πŸ»β€β™‚οΈ .

etCoderDysto avatar Dec 04 '24 10:12 etCoderDysto

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

melvin-bot[bot] avatar Dec 23 '24 21:12 melvin-bot[bot]

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

  • https://github.com/Expensify/App/pull/53630
  • https://github.com/Expensify/App/pull/54203

If no regressions arise, payment will be issued on 2024-12-30. :confetti_ball:

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

melvin-bot[bot] avatar Dec 23 '24 21:12 melvin-bot[bot]

@shubham1206agra @zanyrenney @shubham1206agra 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[bot] avatar Dec 23 '24 21:12 melvin-bot[bot]

@cristipaval, @FitseTLT, @zanyrenney, @shubham1206agra Whoops! This issue is 2 days overdue. Let's get this updated quick!

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

@shubham1206agra please complete the checklist in the comment here so I can issue payout -- https://github.com/Expensify/App/issues/53315#issuecomment-2560292463

zanyrenney avatar Jan 03 '25 18:01 zanyrenney

Thank you!

zanyrenney avatar Jan 03 '25 18:01 zanyrenney

bump @shubham1206agra

zanyrenney avatar Jan 06 '25 12:01 zanyrenney

I hve DM'd @shubham1206agra

zanyrenney avatar Jan 06 '25 12:01 zanyrenney

BugZero Checklist:

  • [x] [Contributor] Classify the bug:
Bug classification

Source of bug:

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

Where bug was reported:

  • [x] 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
  • [x] 3d. QA
  • [ ] 3z. Other:
  • [x] [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: https://github.com/Expensify/App/pull/36178/files#r1904109986

  • [x] [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: NA

  • [x] [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.

  • [ ] [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Precondition:

  • Account only has one workspace.
  • Invoices feature is enabled.

Test:

  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. Go to FAB > Start chat > Room.
  7. Click Workspace.
  8. Observe that only one workspace is present in the workspace list.

Do we agree πŸ‘ or πŸ‘Ž

shubham1206agra avatar Jan 06 '25 12:01 shubham1206agra

@zanyrenney Can you send the offer again?

shubham1206agra avatar Jan 07 '25 12:01 shubham1206agra

@cristipaval, @FitseTLT, @zanyrenney, @shubham1206agra Eep! 4 days overdue now. Issues have feelings too...

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