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

[HOLD for payment 2024-08-09] [$250] Workspace switcher - WS switcher and LHN are not reset to Expensify after leaving workspace #43981

Closed
6 tasks done
izarutskaya opened this issue Jun 19, 2024 · 33 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Jun 19, 2024

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.85-4
Reproducible in staging?: Y
Reproducible in production?: Y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

Precondition:

  • User is invited to a workspace.
  1. Go to staging.new.expensify.com
  2. Open workspace switcher.
  3. Select the invited workspace.
  4. Go to Account settings > Workspaces.
  5. Click 3-dot menu on the invited workspace > Leave.
  6. Return to LHN.

Expected Result:

  • Workspace switcher will switch to Expensify.
  • LHN will show all the chats because Expensify is selected.

Actual Result:

  • Workspace switcher displays Expensify, but when opening the workspace list, Expensify is not selected.
  • LHN still shows the filtered chats.

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

20240619_131605.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~018dbe15d720ffa01b
  • Upwork Job ID: 1804259959268757378
  • Last Price Increase: 2024-06-21
  • Automatic offers:
    • truph01 | Contributor | 103068211
Issue OwnerCurrent Issue Owner: @johncschuster
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 19, 2024
Copy link

melvin-bot bot commented Jun 19, 2024

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

@izarutskaya
Copy link
Author

izarutskaya commented Jun 19, 2024

We think this issue might be related to the #vip-vsb

@tsa321
Copy link
Contributor

tsa321 commented Jun 19, 2024

Proposal

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

Workspace switcher - WS switcher and LHN are not reset to Expensify after leaving workspace

What is the root cause of that problem?

We don't have check on currently accessed policy, whether the user is still member of the policy or the policy is not deleted, Inside callback of Onyx connect to policy collection.

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

We can make a callback in onyx policy collection, then check if currently accessed policy is deleted or the user is not member anymore, then updateLastAccessedWorkspace(undefined);

Is this expected result? Or should we show modal if the remove member or delete workspace action are from other user?
the confirm modal could be. You are no longer member of ..... Then ask Do you want to change the workspace Expensify? ` if user is in report screen.

@truph01
Copy link
Contributor

truph01 commented Jun 19, 2024

Proposal

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

Workspace switcher displays Expensify, but when opening the workspace list, Expensify is not selected.
LHN still shows the filtered chats.

What is the root cause of that problem?

In deleteWorkspace function

// Reset the lastAccessedWorkspacePolicyID
if (policyID === lastAccessedWorkspacePolicyID) {
updateLastAccessedWorkspace(undefined);
}
}

We have logic to update the lastAccessedWorkspacePolicyID, but we missed it in the leaveWorkspace function

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

  • We can add a new listener to BaseSidebarScreen component:
    const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
    const selectedPolicy = Object.values(policies ?? {}).find((o) => o?.id === activeWorkspaceID);
    const prevSelectedPolicy = usePrevious(selectedPolicy);
    useEffect(() => {
        if (!selectedPolicy && !prevSelectedPolicy) {
            return;
        }
        if (prevSelectedPolicy && !selectedPolicy && activeWorkspaceID !== undefined) {
            Navigation.navigateWithSwitchPolicyID({policyID: undefined});
            updateLastAccessedWorkspace(undefined);
        }
    }, [prevSelectedPolicy, selectedPolicy, activeWorkspaceID]);
  • So once the selected policy is undefined, it will switch to the default policy.

What alternative solutions did you explore? (Optional)

API.write(WRITE_COMMANDS.LEAVE_POLICY, params, {optimisticData, successData, failureData});

here, we also should add

if (policyID === lastAccessedWorkspacePolicyID) {
        updateLastAccessedWorkspace(undefined);
    }

@melvin-bot melvin-bot bot added the Overdue label Jun 21, 2024
@johncschuster johncschuster added the External Added to denote the issue can be worked on by a contributor label Jun 21, 2024
@melvin-bot melvin-bot bot changed the title Workspace switcher - WS switcher and LHN are not reset to Expensify after leaving workspace [$250] Workspace switcher - WS switcher and LHN are not reset to Expensify after leaving workspace Jun 21, 2024
Copy link

melvin-bot bot commented Jun 21, 2024

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

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

melvin-bot bot commented Jun 21, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Jun 21, 2024
@s77rt
Copy link
Contributor

s77rt commented Jun 23, 2024

@tsa321

In Policy.leaveWorkspace we don't have logic to check current workspace is leaved workspace, then navigate to all expensify chats

This is not the root cause. I don't see why such logic should be a part of the leaveWorkspace call. Also this will not fix the problem if the admin removed you (as a member) from the workspace

@s77rt
Copy link
Contributor

s77rt commented Jun 23, 2024

@truph01 Same note as above ^ Adding the check to the leaveWorkspace will only fix the problem if you leave the workspace but what about if another admin removes you from that workspace?

@tsa321
Copy link
Contributor

tsa321 commented Jun 23, 2024

@s77rt How about we make a callback in onyx policy collection, then check if currently accessed policy is deleted or user is not member of the currently accessed policy anymore, then updateLastAccessedWorkspace(undefined);

Is this expected result? Or should we show modal if the remove member or delete workspace action are from other user?
the confirm modal could be. You are no longer member of ..... Then ask Do you want to change the workspace Expensify? ` if user is in report screen.

Proposal

updated

@s77rt
Copy link
Contributor

s77rt commented Jun 23, 2024

@tsa321 I'd prefer not to relay on Onyx callbacks. Can we go with the same approach as reports? We have a useEffect on ReportScreen that handles report deletion

@melvin-bot melvin-bot bot added the Overdue label Jun 25, 2024
@truph01
Copy link
Contributor

truph01 commented Jun 25, 2024

Proposal updated

  • @s77rt I updated my main solution based on your suggestion above.

@s77rt
Copy link
Contributor

s77rt commented Jun 26, 2024

@truph01 I noticed that If I select a workspace that I created and then delete it, the bug does not occur. Can you investigate that and why the bug only occurs on invited workspaces? That should help us find a better solution

@melvin-bot melvin-bot bot removed the Overdue label Jun 26, 2024
@truph01
Copy link
Contributor

truph01 commented Jun 26, 2024

@s77rt

  • When deleting the workspace, we call:

    if (activeWorkspaceID === policyIDToDelete) {
    setActiveWorkspaceID(undefined);
    Navigation.navigateWithSwitchPolicyID({policyID: undefined});
    }

    it is the same as what we do when switching to "Expensify" workspace. So the bug does not occur when we delete our workspaces that we are owner. Below is the detail.

  • There are two ways to get the current active workspace, one is from ACTIVE_WORKSPACE_ID in session storage and one is from the navigation state.

  • setActiveWorkspaceID(undefined): It will set the ACTIVE_WORKSPACE_ID in session storage to undefined. With this data, in workspace switcher page, the "Expensify" is displayed with "ticked" icon.

  • Navigation.navigateWithSwitchPolicyID({policyID: undefined}): It will update the navigation state. With this data, in LHN, we display all the reports without filtering.

@truph01
Copy link
Contributor

truph01 commented Jun 26, 2024

Update comment

@s77rt
Copy link
Contributor

s77rt commented Jun 26, 2024

@truph01 Ah right. In your proposal we are not calling setActiveWorkspaceID though but updateLastAccessedWorkspace. Won't this make the workspace switcher page has not selected option?

@truph01
Copy link
Contributor

truph01 commented Jun 26, 2024

@s77rt Yes, we do not need to call setActiveWorkspaceID because we already call it in:

const handleStateChange = (state: NavigationState | undefined) => {
if (!state) {
return;
}
const activeWorkspaceID = getPolicyIDFromState(state as NavigationState<RootStackParamList>);
// Performance optimization to avoid context consumers to delay first render
setTimeout(() => {
currentReportIDValue?.updateCurrentReportID(state);
setActiveWorkspaceID(activeWorkspaceID);
}, 0);
parseAndLogRoute(state);
// We want to clean saved scroll offsets for screens that aren't anymore in the state.
cleanStaleScrollOffsets(state);
};

@s77rt
Copy link
Contributor

s77rt commented Jun 26, 2024

@truph01 Makes sense! Overall the proposal looks good to me

🎀 👀 🎀 C+ reviewed
Link to proposal

Copy link

melvin-bot bot commented Jun 26, 2024

Triggered auto assignment to @cristipaval, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 5, 2024
@s77rt
Copy link
Contributor

s77rt commented Jul 8, 2024

Same ^

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 8, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 10, 2024
Copy link

melvin-bot bot commented Jul 10, 2024

📣 @truph01 🎉 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 melvin-bot bot removed the Overdue label Jul 10, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jul 11, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 2, 2024
@melvin-bot melvin-bot bot changed the title [$250] Workspace switcher - WS switcher and LHN are not reset to Expensify after leaving workspace [HOLD for payment 2024-08-09] [$250] Workspace switcher - WS switcher and LHN are not reset to Expensify after leaving workspace Aug 2, 2024
Copy link

melvin-bot bot commented Aug 2, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 2, 2024
Copy link

melvin-bot bot commented Aug 2, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.15-9 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-08-09. 🎊

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

Copy link

melvin-bot bot commented Aug 2, 2024

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:

  • [@s77rt] The PR that introduced the bug has been identified. Link to the PR:
  • [@s77rt] 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:
  • [@s77rt] 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:
  • [@s77rt] Determine if we should create a regression test for this bug.
  • [@s77rt] 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.
  • [@johncschuster] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@s77rt s77rt mentioned this issue Aug 5, 2024
50 tasks
@s77rt
Copy link
Contributor

s77rt commented Aug 5, 2024

  • The PR that introduced the bug has been identified: More like a missed case [Wave 8] Ideal nav  #33280
  • The offending PR has been commented on: [Wave 8] Ideal nav  #33280 (comment)
  • A discussion in #expensify-bugs has been started: Not needed, one of a kind bug
  • Determine if we should create a regression test for this bug: No, low priority

@johncschuster
Copy link
Contributor

Acknowledged! I'll issue payment after the regression threshold is cleared.

@johncschuster
Copy link
Contributor

johncschuster commented Aug 7, 2024

Payment Summary

Contributor: @truph01 paid $250 via Upwork (paid on 2024-08-09)
Contributor+: @s77rt owed $250 via NewDot

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Aug 8, 2024
@johncschuster
Copy link
Contributor

Payment has been issued via Upwork to @truph01. Go ahead and request payment on ND, @s77rt! Thank you both for your contributions! 🎉

@JmillsExpensify
Copy link

$250 approved for @s77rt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Archived in project
Development

No branches or pull requests

7 participants