Repository navigation
[HOLD for payment 2024-04-15] [$500] Room - WS is not shown empty on setting collect WS as default. #37656
Description
Activity
- addedDailyKSv2KSv2BugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.
on Mar 2, 2024 Triggered auto assignment to @MitchExpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.@MitchExpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
Proposal
Please re-state the problem that we are trying to solve in this issue.
WS is not shown empty on setting collect WS as default
What is the root cause of that problem?
In
useEffect, we set PolicyID toactivePolicyIDwhen the any value fromworkspaceOptionsmatchactivePolicyID
App/src/pages/workspace/WorkspaceNewRoomPage.tsx
Lines 128 to 140 in 22cb01c
useEffect(() => { if (policyID) { if (!workspaceOptions.some((opt) => opt.value === policyID)) { setPolicyID(''); } return; } if (!!activePolicyID && workspaceOptions.some((opt) => opt.value === activePolicyID)) { setPolicyID(activePolicyID); } else { setPolicyID(''); } }, [activePolicyID, policyID, workspaceOptions]); And this further sets the default value over here:
App/src/pages/workspace/WorkspaceNewRoomPage.tsx
Lines 287 to 294 in 22cb01c
<InputWrapper InputComponent={ValuePicker} inputID={INPUT_IDS.POLICY_ID} label={translate('workspace.common.workspace')} items={workspaceOptions} value={policyID} onValueChange={(value) => setPolicyID(value as typeof policyID)} /> What changes do you think we should make in order to solve the problem?
In
useEffectas well asuseState, we must add one more condition to check for the type of the current option and only set the policy id to the active one if it is not equal toteam:Essentially we would set
setPolicyIDto empty string inuseEffectand return empty string inuseStateThe update would be like:const [policyID, setPolicyID] = useState<string>(() => { if (!!activePolicyID && workspaceOptions.some((option) => (option.value === activePolicyID && option.type !== CONST.POLICY.TYPE.TEAM))) { return activePolicyID; } return ''; }); useEffect(() => { ..... if (!!activePolicyID && workspaceOptions.some((opt) => (opt.value === activePolicyID && opt.type !== CONST.POLICY.TYPE.TEAM))) { setPolicyID(activePolicyID); }
The type property is inherited from
workspaceOptions, we will define a new variable as type which is present in policyApp/src/pages/workspace/WorkspaceNewRoomPage.tsx
Lines 73 to 83 in 22cb01c
const workspaceOptions = useMemo( () => PolicyUtils.getActivePolicies(policies) ?.filter((policy) => policy.type !== CONST.POLICY.TYPE.PERSONAL) .map((policy) => ({ label: policy.name, value: policy.id, })) .sort((a, b) => localeCompare(a.label, b.label)) ?? [], [policies], ); Result:
simplescreenrecorder-2024-03-03_05.58.41.mp4
I'm not sure why we'd want the Workspace field to show be blank here on the room creation screen. I'd expect us to show the Collect default workspace in the workspace field which seems to be what is happening - Rigth @lanitochka17 ?
Proposal
Please re-state the problem that we are trying to solve in this issue.
Room - WS is not shown empty on setting collect WS as default.
What is the root cause of that problem?
I believe the current behavior is partially correct. When a user has set a default workspace, it should be selected as the default in the room creation flow. However, the issue arises when the user switches to a different workspace in NewDot from the workspace switcher. When the user creates a room, the default workspace remains the default from the OldDot. In my opinion, for better user experience, we should select the newly selected workspace from NewDot.
Bug Video
default_workspace_bug.mp4
What changes do you think we should make in order to solve the problem?
Instead of checking for
activePolicyIDfrom OldDot first, we should verify whether the user has selected any workspace from NewDot. If there is no selected workspace in NewDot, we will set the default toactivePolicyIDfrom OldDot. We can obtain the active workspace in NewDot usingconst {activeWorkspaceID} = useActiveWorkspace(). Then, we can useconst activeID = activeWorkspaceID ?? activePolicyID;to obtain the default value for policyID.We will replace
activePolicyIDwithactiveID.Result
default_ws.mp4
Alternative
If we want to always show empty default WS we can remove code blocks below:
App/src/pages/workspace/WorkspaceNewRoomPage.tsx
Lines 85 to 87 in 4231ac9
if (!!activePolicyID && workspaceOptions.some((option) => option.value === activePolicyID)) { return activePolicyID; } App/src/pages/workspace/WorkspaceNewRoomPage.tsx
Lines 135 to 137 in 4231ac9
if (!!activePolicyID && workspaceOptions.some((opt) => opt.value === activePolicyID)) { setPolicyID(activePolicyID); } else { @MitchExpensify, can you please provide some feedback on this? Thanks
I believe the current behavior is partially correct. When a user has set a default workspace, it should be selected as the default in the room creation flow. However, the issue arises when the user switches to a different workspace in NewDot from the workspace switcher. When the user creates a room, the default workspace remains the default from the OldDot. In my opinion, for better user experience, we should select the newly selected workspace from NewDot.
Bug Video
default_workspace_bug.mp4
Yeah this is an interesting question @Krishna2323 - Should the workspace you are filtering by in NewDot be shown as the default workspace when creating a room? I think the answer is "yes" and I'll double-check internally that others agree!
@MitchExpensify, any updates?
Should the workspace you are filtering by in NewDot be shown as the default workspace when creating a room?
@MitchExpensify I think collect workspaces are still not show by default in ND, we need to run a script when we create new collect policy in OD for it to show in ND, so I think not relying on ND workspace is a safe option
(not 100% sure about this, but just thought this out loud :) )
I'm not sure why we'd want the Workspace field to show be blank here on the room creation screen.
We are updating ND to create collect workspaces by default, with this change, we give the user 7 day free trail, when it is over then we don't want the user to create a room with the expired workspace, and hence i think the expected behavior is mentioned in the issue
Double checking what the team thinks!
41 remaining items
Reviewinglabel has been removed, please complete the "BugZero Checklist".The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.60-13 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 2024-04-15. 🎊
For reference, here are some details about the assignees on this issue:
- @hoangzinh requires payment (Needs manual offer from BZ)
- @Krishna2323 requires payment (Needs manual offer from BZ)
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
- [@hoangzinh] The PR that introduced the bug has been identified. Link to the PR:
- [@hoangzinh] 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:
- [@hoangzinh] A discussion in #expensify-bugs 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:
- [@hoangzinh] Determine if we should create a regression test for this bug.
- [@hoangzinh] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
- [@MitchExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
Payment summary:
- C: @Krishna2323 $500 Upwork
- C+: @hoangzinh $500 Upwork
Friendly bump on your regression step suggestion @hoangzinh 🙇
Offers sent for payment on this Job https://www.upwork.com/jobs/~014b390ee1a3dc9cad
@MitchExpensify thanks, accepted 😁
Payment Summary
- ROLE: @hoangzinh paid $(AMOUNT) via Upwork (LINK)
- ROLE: @Krishna2323 paid $(AMOUNT) via Upwork (LINK)
BugZero Checklist (@MitchExpensify)
- 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//hired)
- I have paid out the Upwork contracts or cancelled the ones that are incorrect
- I have verified the payment summary above is correct
paid, thanks @Krishna2323 !
Reacted by KrishnaRegression Test Proposal
Pre-condition: User must have a default workspace and some other workspaces in OldDot
- Sign in to New Dot
- Tap FAB => Start chat
- Select tab Room
- Verify the default WS from OldDot is auto-selected in the workspace select box
- Close "Start chat" modal
- Open the workspace switcher => select any other workspace
- Repeat step 2->3
- Verify that the workspace selected in step 5 is auto-selected in the workspace select box
Do we agree 👍 or 👎
BugZero Checklist:
- The PR that introduced the bug has been identified. Link to the PR: I think there is no PR causing this issue. It's a new requirement/expected result.
- 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: N/A
- A discussion in #expensify-bugs 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: N/A
- Determine if we should create a regression test for this bug: Yes
@MitchExpensify could you process payment for me in upwork? Thanks
Done!
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsNo status

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 1.4.46
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4359738
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:
Action Performed:
Pre-condition: User A in old dot must have a collect workspace
Expected Result:
The Workspace you are currently filtering by should be shown as the top suggested option when creating a room. If filtering by all, your default workspace should be shown as the top suggested option when creating a room.
Actual Result:
Workspace is not shown empty on setting personal Workspace as default
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6399190_1709557892248.changee.mp4
View all open jobs on GitHub