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-11-20] [$250] Web - Workspace - Members are unselected when refresh Add message page and go back #49256

Closed
1 of 6 tasks
IuliiaHerets opened this issue Sep 16, 2024 · 58 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

@IuliiaHerets
Copy link

IuliiaHerets commented Sep 16, 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: 9.0.34-2
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): applausetester+gm103117@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

  1. Create Workspace
  2. Go to Members> Invite> Enter any email> Next
  3. Refresh the Add message page
  4. Go back to Invite members page

Expected Result:

Members should be selected

Actual Result:

Members are deselected

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6602434_1726237027827.Recording__3926.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021836242370984040873
  • Upwork Job ID: 1836242370984040873
  • Last Price Increase: 2024-10-09
  • Automatic offers:
    • alitoshmatov | Reviewer | 104523604
    • truph01 | Contributor | 104523606
Issue OwnerCurrent Issue Owner: @alitoshmatov
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 16, 2024
Copy link

melvin-bot bot commented Sep 16, 2024

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

@IuliiaHerets
Copy link
Author

@RachCHopkins 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

@nyomanjyotisa
Copy link
Contributor

Proposal

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

Web - Workspace - Members are unselected when refresh Add message page and go back

What is the root cause of that problem?

The useEffect in here clears selected members when the component unmounts

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

Remove the following codes

useEffect(() => {
return () => {
Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
};
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [route.params.policyID]);

What alternative solutions did you explore? (Optional)

@Krishna2323
Copy link
Contributor

Krishna2323 commented Sep 16, 2024

Proposal


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

Web - Workspace - Members are unselected when refresh Add message page and go back

What is the root cause of that problem?

  • The useEffect to clear the selected participants runs on initial render because we have route.params.policyID in the dependencies.
    useEffect(() => {
    return () => {
    Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
    };
    // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    }, [route.params.policyID]);

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


  • We can remove route.params.policyID from the dependencies list.

What alternative solutions did you explore? (Optional)

  • We can update the useEffect to only run the cleanup function when component has been already mounted for once.
    useEffect(() => {
        return () => {
            if (firstRenderRef.current) {
                return;
            }
            Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
        };
        // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    }, [route.params.policyID]);

Result

@RachCHopkins
Copy link
Contributor

Reproduced!

@RachCHopkins RachCHopkins added the External Added to denote the issue can be worked on by a contributor label Sep 18, 2024
@melvin-bot melvin-bot bot changed the title Web - Workspace - Members are unselected when refresh Add message page and go back [$250] Web - Workspace - Members are unselected when refresh Add message page and go back Sep 18, 2024
Copy link

melvin-bot bot commented Sep 18, 2024

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

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

melvin-bot bot commented Sep 18, 2024

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

Copy link

melvin-bot bot commented Sep 23, 2024

@RachCHopkins, @alitoshmatov Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Sep 23, 2024
@truph01
Copy link
Contributor

truph01 commented Sep 24, 2024

Proposal

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

  • Members are deselected

What is the root cause of that problem?

  • This feature worked well after PR but PR caused this bug. Reverting that PR will fix this bug.
    In that PR, we introduce a new condition isLoadingPolicy in:

    if ((isLoadingPolicy || isLoadingReportData) && isEmpty(policy) && isEmpty(policyDraft)) {

    The WorkspaceInvitePage component is wrapped in withPolicyAndFullscreenLoading. In withPolicyAndFullscreenLoading, the isLoadingPolicy will be changed from false > true > false ... > false, hence the WorkspaceInvitePage component is mounted > unmounted > mounted.

  • As observed, when we visit the workspace invite page, the WorkspaceInvitePage component mounts twice and unmounts once. This causes the cleanup function

return () => {
Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
};

to be called unnecessarily, contributing to the current bug and impacting the app's performance.

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

  • The cleanup function:

    Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});

    should be called when the workspace invite page is unmounted, not when the WorkspaceInvitePage is unmounted. These two components are different: WorkspaceInvitePage is wrapped inside withPolicyAndFullscreenLoading, in other words, WorkspaceInvitePage is wrapped inside the workspace invite page.

  • So we need to remove that clean-up function:

useEffect(() => {
return () => {
Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
};
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [route.params.policyID]);

and use:

    useEffect(() => {
        const unsubscribe = navigation.addListener('beforeRemove', () => {
            Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
        });

        return unsubscribe;
    }, [navigation, route.params.policyID]);

What alternative solutions did you explore? (Optional)

@RachCHopkins
Copy link
Contributor

@alitoshmatov can you take a look at this proposal please?

@alitoshmatov
Copy link
Contributor

Working on it

@melvin-bot melvin-bot bot removed the Overdue label Sep 25, 2024
Copy link

melvin-bot bot commented Sep 25, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@alitoshmatov
Copy link
Contributor

@nyomanjyotisa Thank you for your proposal. I think your RCA is not correct, that piece of code was added to solve this exact issue

@alitoshmatov
Copy link
Contributor

@Krishna2323 @truph01 Thank you for your proposals. If the root cause is component mounting and unmounting multiple times, shouldn't we fix this problem rather than changing cleanup function to accommodate this multiple mounting.

@truph01
Copy link
Contributor

truph01 commented Sep 26, 2024

shouldn't we fix this problem

Why did you think like that?

@truph01
Copy link
Contributor

truph01 commented Sep 26, 2024

rather than changing cleanup function to accommodate this multiple mounting.

My proposal does not do like that.

The current page's structure is <page><component /></page>. The bug occurs because <component /> is mounting and unmounting multiple times, and the cleanup function is inside <component />. My proposal is to move the cleanup function to <page /> instead of <component />, which should resolve the issue.

Copy link

melvin-bot bot commented Sep 30, 2024

@RachCHopkins @alitoshmatov this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@melvin-bot melvin-bot bot added the Overdue label Sep 30, 2024
@Krishna2323
Copy link
Contributor

If the root cause is component mounting and unmounting multiple times, shouldn't we fix this problem rather than changing cleanup function to accommodate this multiple mounting.

@alitoshmatov I don't think multiple renders are the problem here because the component will render twice or multiple times when the onyx data changes.

if ((isLoadingPolicy || isLoadingReportData) && isEmpty(policy) && isEmpty(policyDraft)) {
return <FullscreenLoadingIndicator />;
}
return (
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
{...(rest as TProps)}

My alternative solution uses the same solution applied for adding the members on initial render.

if (firstRenderRef.current) {
// We only want to add the saved selected user on first render
firstRenderRef.current = false;
Object.keys(invitedEmailsToAccountIDsDraft ?? {}).forEach((login) => {
if (!(login in detailsMap)) {
return;
}
newSelectedOptions.push({...detailsMap[login], isSelected: true});
});
}

Copy link

melvin-bot bot commented Oct 21, 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 📖

@truph01
Copy link
Contributor

truph01 commented Oct 22, 2024

@neil-marcellini @alitoshmatov I've created a draft PR, but I'm encountering an error in step 3 when refreshing the Add Message page. I've reached out to the author of the PR for clarification on what might be causing the issue.

@melvin-bot melvin-bot bot added the Overdue label Oct 23, 2024
@neil-marcellini
Copy link
Contributor

Ok sounds good. Please keep debugging yourself as well.

@melvin-bot melvin-bot bot removed the Overdue label Oct 23, 2024
Copy link

melvin-bot bot commented Oct 29, 2024

@neil-marcellini, @RachCHopkins, @alitoshmatov, @truph01 Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added Overdue Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 Overdue labels Oct 29, 2024
@truph01
Copy link
Contributor

truph01 commented Oct 30, 2024

PR is ready

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 13, 2024
@melvin-bot melvin-bot bot changed the title [$250] Web - Workspace - Members are unselected when refresh Add message page and go back [HOLD for payment 2024-11-20] [$250] Web - Workspace - Members are unselected when refresh Add message page and go back Nov 13, 2024
Copy link

melvin-bot bot commented Nov 13, 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 Nov 13, 2024
Copy link

melvin-bot bot commented Nov 13, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.60-3 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-11-20. 🎊

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

Copy link

melvin-bot bot commented Nov 13, 2024

@alitoshmatov @RachCHopkins @alitoshmatov 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 melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 19, 2024
@RachCHopkins
Copy link
Contributor

@alitoshmatov can you please do the checklist before I pay this tomorrow?

@alitoshmatov
Copy link
Contributor

alitoshmatov commented Nov 20, 2024

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

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

Where bug was reported:

  • 2a. Reported on production
  • 2b. Reported on staging (deploy blocker)
  • 2c. Reported on both staging and production
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [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/48872/files#r1850053493

  • [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: Not critical

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

No regression needed

@RachCHopkins
Copy link
Contributor

Payment Summary:

  • Contributor: @truph01 to be paid $250 via Upwork
  • Contributor+: @alitoshmatov to be paid $250 via Upwork

Upwork job here

@RachCHopkins
Copy link
Contributor

Contributors have been paid, the contracts have been completed, and the Upwork post has been closed.

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
Status: Done
Development

No branches or pull requests

8 participants