Skip to content

[HOLD for payment 2024-04-15] [$500] Room - WS is not shown empty on setting collect WS as default. #37656

Description

@lanitochka17

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

  1. Launch app with user A
  2. As same user login old dot
  3. Set Collect Workspace as default
  4. In new dot, tap fab --- start chat
  5. Tap room
  6. Note the Workspace field

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?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6399190_1709557892248.changee.mp4

View all open jobs on GitHub

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 2, 2024
  2. melvin-bot commented on Mar 2, 2024

    @melvin-bot

    Triggered auto assignment to @MitchExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  3. lanitochka17 commented on Mar 2, 2024

    @lanitochka17
    Author

    @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

  4. allgandalf commented on Mar 3, 2024

    @allgandalf
    Contributor

    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 to activePolicyID when the any value from workspaceOptions match activePolicyID

    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:

    <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 useEffect as well as useState , 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 to team:

    image

    Essentially we would set setPolicyID to empty string in useEffect and return empty string in useState The 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 policy

    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
  5. MitchExpensify commented on Mar 3, 2024

    @MitchExpensify
    Contributor

    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 ?

  6. Krishna2323 commented on Mar 4, 2024

    @Krishna2323
    Contributor

    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 activePolicyID from 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 to activePolicyID from OldDot. We can obtain the active workspace in NewDot using const {activeWorkspaceID} = useActiveWorkspace(). Then, we can use const activeID = activeWorkspaceID ?? activePolicyID; to obtain the default value for policyID.

    We will replace activePolicyID with activeID.

    Result

    default_ws.mp4

    Alternative

    If we want to always show empty default WS we can remove code blocks below:

    if (!!activePolicyID && workspaceOptions.some((option) => option.value === activePolicyID)) {
    return activePolicyID;
    }

    if (!!activePolicyID && workspaceOptions.some((opt) => opt.value === activePolicyID)) {
    setPolicyID(activePolicyID);
    } else {

  7. Krishna2323 commented on Mar 4, 2024

    @Krishna2323
    Contributor

    @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
  8. MitchExpensify commented on Mar 6, 2024

    @MitchExpensify
    Contributor

    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!

  9. Krishna2323 commented on Mar 8, 2024

    @Krishna2323
    Contributor

    @MitchExpensify, any updates?

  10. allgandalf commented on Mar 8, 2024

    @allgandalf
    Contributor

    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

  11. MitchExpensify commented on Mar 10, 2024

    @MitchExpensify
    Contributor

    Double checking what the team thinks!

  12. 41 remaining items

  13. melvin-bot commented on Apr 8, 2024

    @melvin-bot

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

  14. melvin-bot commented on Apr 8, 2024

    @melvin-bot

    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)
  15. melvin-bot commented on Apr 8, 2024

    @melvin-bot

    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:
  16. MitchExpensify commented on Apr 9, 2024

    @MitchExpensify
    Contributor

    Payment summary:

  17. MitchExpensify commented on Apr 15, 2024

    @MitchExpensify
    Contributor

    Friendly bump on your regression step suggestion @hoangzinh 🙇

    Offers sent for payment on this Job https://www.upwork.com/jobs/~014b390ee1a3dc9cad

  18. Krishna2323 commented on Apr 15, 2024

    @Krishna2323
    Contributor

    @MitchExpensify thanks, accepted 😁

  19. melvin-bot commented on Apr 15, 2024

    @melvin-bot

    Payment Summary

    Upwork Job

    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
  20. MitchExpensify commented on Apr 15, 2024

    @MitchExpensify
    Contributor

    paid, thanks @Krishna2323 !

  21. hoangzinh commented on Apr 17, 2024

    @hoangzinh
    Contributor

    Regression Test Proposal

    Pre-condition: User must have a default workspace and some other workspaces in OldDot

    1. Sign in to New Dot
    2. Tap FAB => Start chat
    3. Select tab Room
    4. Verify the default WS from OldDot is auto-selected in the workspace select box
    5. Close "Start chat" modal
    6. Open the workspace switcher => select any other workspace
    7. Repeat step 2->3
    8. Verify that the workspace selected in step 5 is auto-selected in the workspace select box

    Do we agree 👍 or 👎

  22. hoangzinh commented on Apr 17, 2024

    @hoangzinh
    Contributor

    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
  23. hoangzinh commented on Apr 19, 2024

    @hoangzinh
    Contributor

    @MitchExpensify could you process payment for me in upwork? Thanks

  24. MitchExpensify commented on Apr 22, 2024

    @MitchExpensify
    Contributor

    Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions