[$250] Room - Deleted workspace appears in workspace list during room creation flow
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.
- Go to staging.new.expensify.com
- Go to FAB > Send invoice.
- Send an invoice to another user.
- As invoice receiver, open the invoice room and pay the invoice via Pay with business.
- Go back to the invoice sender.
- Delete the workspace.
- Create a new workspace.
- Go to FAB > Start chat > Room.
- Click Workspace.
- Note that the deleted workspace is still present in the workspace list.
- 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
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 Owner
Current Issue Owner: @FitseTLT
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.
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..
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
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:
- the above proposal didn't identify the right problem and RCA
-
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)
Job added to Upwork: https://www.upwork.com/jobs/~021863656321139042808
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rayane-djouah (External)
hey there @rayane-djouah please could you review the proposals above if either are suitable?
Thank you!
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
Member
Admin
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.
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
Commenting here as per slack convo
Assigning @shubham1206agra as the C+ since @rayane-djouah hasn't reviewed the proposals yet. We chatted here about the issue.
I have discussed this with @cristipaval about this. And we have decided to assign @etCoderDysto's proposal.
πππ C+ reviewed
Current assignee @cristipaval is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.
@FitseTLT and @etCoderDysto Fair warning to both of you. Be civil in the discussion. Otherwise, it will result in permanent ban from here.
ah, no, sorry, my bad in that Slack channel. I wanted to actually point to @FitseTLT proposal.
@cristipaval You can assign @FitseTLT then.
π£ @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 π
@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.
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 ππ»ββοΈ .
Reviewing label has been removed, please complete the "BugZero Checklist".
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:
- @FitseTLT requires payment automatic offer (Contributor)
- @shubham1206agra requires payment automatic offer (Contributor)
@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]
@cristipaval, @FitseTLT, @zanyrenney, @shubham1206agra Whoops! This issue is 2 days overdue. Let's get this updated quick!
@shubham1206agra please complete the checklist in the comment here so I can issue payout -- https://github.com/Expensify/App/issues/53315#issuecomment-2560292463
Thank you!
bump @shubham1206agra
I hve DM'd @shubham1206agra
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:
- Go to staging.new.expensify.com
- Go to FAB > Send invoice.
- Send an invoice to another user.
- As invoice receiver, open the invoice room and pay the invoice via Pay with business.
- Go back to the invoice sender.
- Go to FAB > Start chat > Room.
- Click Workspace.
- Observe that only one workspace is present in the workspace list.
Do we agree π or π
@zanyrenney Can you send the offer again?
@cristipaval, @FitseTLT, @zanyrenney, @shubham1206agra Eep! 4 days overdue now. Issues have feelings too...