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 2023-10-25] [$500] Workspace - Selected members unselect on switch from offline to online #28551

Closed
6 tasks done
lanitochka17 opened this issue Sep 30, 2023 · 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

@lanitochka17
Copy link

lanitochka17 commented Sep 30, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Go to Settings > Workspaces > Members
  2. Go offline
  3. Click on invite button
  4. Enter email which is not in list and invite that user
  5. From Members screen select that user
  6. Go online

Expected Result:

Selected should not unselect automatically

Actual Result:

Selected members unselect automatically

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.75-0

Reproducible in staging?: Yes

Reproducible in production?: Yes

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

Screen_Recording_20230929_142421_Chrome_1.mp4
Screen.Recording.2023-09-29.at.2.22.45.PM.mov
Screen_Recording_20230929_140311_New.Expensify.mp4
Screen.Recording.2023-09-29.at.2.09.26.PM.mov
RPReplay_Final1695976855.MP4
RPReplay_Final1695976972.MP4
Recording.116.mp4

Expensify/Expensify Issue URL:

Issue reported by: @gadhiyamanan

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695976528390539

View all open jobs on GitHub

@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 30, 2023
@melvin-bot melvin-bot bot changed the title Workspace - Selected members unselect on switch from offline to online [$500] Workspace - Selected members unselect on switch from offline to online Sep 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 30, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 30, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 30, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

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

melvin-bot bot commented Sep 30, 2023

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

@ZhenjaHorbach
Copy link
Contributor

ZhenjaHorbach commented Sep 30, 2023

Proposal

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

Selected new members unselect automatically after switch from offline to online

What is the root cause of that problem?

The main problem is that the selected elements are stored as ids
But since after that we gain access to the Internet, new IDs are generated for elements created offline

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

Once we have access to the Internet
We can check old items by login and replace the old IDs with new ones if there is a match

useEffect(() => {
if (removeMembersConfirmModalVisible && !_.isEqual(accountIDs, prevAccountIDs)) {
setRemoveMembersConfirmModalVisible(false);
}
setSelectedEmployees((prevSelected) =>
_.intersection(
prevSelected,
_.map(_.values(PolicyUtils.getMemberAccountIDsForWorkspace(props.policyMembers, props.personalDetails)), (accountID) => Number(accountID)),
),
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [props.policyMembers]);

We can update this useEffect like

    useEffect(() => {
        if (removeMembersConfirmModalVisible && !_.isEqual(accountIDs, prevAccountIDs)) {
            setRemoveMembersConfirmModalVisible(false);
        }

        setSelectedEmployees((prevSelected) => {
            const prevSelectedElements = _.map(prevSelected, (id) => {
                const res = _.find(_.values(props.personalDetails), (item) => _.lodashGet(prevPersonalDetails[id],'login') === _.lodashGet(item,'login'));
                return res.accountID;
            });
            return _.intersection(
		prevSelectedElements,
                _.map(_.values(PolicyUtils.getMemberAccountIDsForWorkspace(props.policyMembers, props.personalDetails)), (accountID) => Number(accountID)),
            );
        });
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [props.policyMembers]);

What alternative solutions did you explore? (Optional)

NA

@abdel-h66
Copy link
Contributor

abdel-h66 commented Oct 1, 2023

Proposal

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

Reconnecting to the network removes selected newly added members from the members list

What is the root cause of that problem?

The newly added members have temporary id that are used to handle the selection in the members list, except that when coming back online that will trigger command=AddMembersToWorkspace which will retrieve the correct user IDs

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

We can start by finding the members with a pending add action using this utility

    const findMembersWithPreviouslyPendingActions = useCallback(() => {

        const membersWithPendingAddActionIds = _.pick(props.policyMembers, (member) => member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);
        const personalDetailsWithPendingAddActionIds = _.pick(props.personalDetails, (personalDetail, accountID) => membersWithPendingAddActionIds[accountID])
    
    
        return _.map(personalDetailsWithPendingAddActionIds, (personalDetail) => personalDetail.login);
    
    }, [props.personalDetails, props.policyMembers])

And then when coming back online, we will try to guess the newly added member real ID using their login which will not change after coming back online, it could be something like this. the code can definitly be imporoved. it's just a quick POC

    useEffect(() => {
        const isReconnecting = prevIsOffline && !props.network.isOffline;

        if(!isReconnecting) {
            return 
        }
        const previouslySelectedEmailsWithPendingActions = findMembersWithPreviouslyPendingActions();

        setMembersWithPreviouslySelectedEmails(_.pick(props.personalDetails, (personalDetail) => _.contains(previouslySelectedEmailsWithPendingActions, personalDetail.login)))
        
    }, [findMembersWithPreviouslyPendingActions, prevIsOffline, props.network.isOffline, props.personalDetails])


    useEffect(() => {
        const emailsOfPreviouslySelectedMembers = _.map(memberWithPreviouslySelectedEmails, (member) => member.login);

        setSelectedEmployees((prevSelected) => {
            const membersToSelect = _.pick(props.personalDetails, (personalDetail) => emailsOfPreviouslySelectedMembers.includes(personalDetail.login) )

            return [...prevSelected, ..._.map(membersToSelect, (member) => Number(member.accountID))]
        })
    }, [memberWithPreviouslySelectedEmails, props.personalDetail, props.personalDetails])
offline.mp4

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot melvin-bot bot added the Overdue label Oct 3, 2023
@mollfpr
Copy link
Contributor

mollfpr commented Oct 3, 2023

@abdel-h66 I'm not sure using personalDetails to change the selected option is the correct way while we definitely use policyMembers to show the members. What is the reason for that?

@melvin-bot melvin-bot bot removed the Overdue label Oct 3, 2023
@abdel-h66
Copy link
Contributor

It's true that we are using the ids from policyMembers to handle the selection, and that's where the issues lies, basically the ID on the policyMembers collection will change once we go online, making us lose the selection. the use of personalDetails will helps us look find for the new ID inside the policyMembers

We then return [...prevSelected, ..._.map(membersToSelect, (member) => Number(member.accountID))] as the only ID is necessary to perform a selection and not the whole object from policyMembers

Here is an example:

  1. Go offline
  2. Invite a new member to the workspace. their email is test22@gmail.com
    This new member will have a random ID generated from the client ID = RANDOM_22
  3. going back to the list and select this ID
  4. The selection now has the [RANDOM_22]
  5. Go online
  6. The command AddMembersToWorkspace will be trigerred
  7. Now our member test22@gmail.com Id will change and become REAL_ID_22

Using my suggestion we know that the member test22@gmail.com has a pending action, we can use that to store the email and then use it to find the new ID REAL_ID_22 and automatically selecting it making the selection now [REAL_ID_22] instead of [RANDOM_22] which no longer exists

I hope this was clear :) let me know if you still have any questions

@mollfpr
Copy link
Contributor

mollfpr commented Oct 3, 2023

t's true that we are using the ids from policyMembers to handle the selection, and that's where the issues lies, basically the ID on the policyMembers collection will change once we go online, making us lose the selection.

I don't understand why using policyMembers is the issue, isn't the accountID on personalDetails changed to when back online?

Also, the personalDetails will not change if we remove a member from another device, so that's why listen to policyMembers change from the pusher and update the selection accordingly.


@ZhenjaHorbach Your solution seems simple enough to solve the issue, but can we map through the previously selected list only if we have members from offline? It seems unnecessary if we add members from existing personalDetails.

@abdel-h66
Copy link
Contributor

The issue with the policyMembers collection is that it does not contain enough information, the personalDetails contains the .login property that I needed to perform the logic :)

@ZhenjaHorbach
Copy link
Contributor

ZhenjaHorbach commented Oct 3, 2023

@mollfpr
I don't think that's a problem
We can use pendingAction field in personalDetails elements for example
And сheck only those elements if pendingAction is not empty)

@mollfpr
Copy link
Contributor

mollfpr commented Oct 4, 2023

We still need to stick with policyMembers to update the selection. So the proposal from @ZhenjaHorbach is simple enough to solve this issue.

🎀 👀 🎀 C+ reviewed!

@melvin-bot
Copy link

melvin-bot bot commented Oct 4, 2023

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

@stephanieelliott
Copy link
Contributor

Hey @Li357 are you working on a PR for this issue?

@melvin-bot melvin-bot bot added the Overdue label Oct 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

@Li357, @mollfpr, @stephanieelliott Whoops! This issue is 2 days overdue. Let's get this updated quick!

@Li357
Copy link
Contributor

Li357 commented Oct 9, 2023

I agree @ZhenjaHorbach is simpler, assigning you!

@melvin-bot melvin-bot bot removed the Overdue label Oct 9, 2023
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 9, 2023
@ZhenjaHorbach
Copy link
Contributor

@stephanieelliott
@Li357
Hello )
Can you please unassign and assign me again?
Because I didn't still get an offer )

@Li357 Li357 assigned ZhenjaHorbach and unassigned ZhenjaHorbach Oct 16, 2023
@stephanieelliott
Copy link
Contributor

Hi @ZhenjaHorbach I've extended the offer to you manually, the job is here!

@ZhenjaHorbach
Copy link
Contributor

Hi @ZhenjaHorbach I've extended the offer to you manually, the job is here!

Thank you )

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 18, 2023
@melvin-bot melvin-bot bot changed the title [$500] Workspace - Selected members unselect on switch from offline to online [HOLD for payment 2023-10-25] [$500] Workspace - Selected members unselect on switch from offline to online Oct 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.86-5 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 2023-10-25. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

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:

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

@mollfpr
Copy link
Contributor

mollfpr commented Oct 25, 2023

The PR that introduced the bug has been identified. Link to the PR:

#17166

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/18934/files#r1371829488

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:

The regression step should be enough.

Determine if we should create a regression test for this bug.
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.

  1. Go to Settings > Workspaces > Members
  2. Go offline
  3. Click on the invite button
  4. Enter an email that is not in the list and invite that user
  5. From the Members screen, select that user
  6. Go online
  7. Verify the selection is remains
  8. 👍 or 👎

@mollfpr
Copy link
Contributor

mollfpr commented Oct 27, 2023

@stephanieelliott Could you give us the payment summary? Thank you!

@melvin-bot melvin-bot bot added the Overdue label Oct 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2023

@Li357, @mollfpr, @stephanieelliott, @ZhenjaHorbach Whoops! This issue is 2 days overdue. Let's get this updated quick!

@stephanieelliott
Copy link
Contributor

Summarizing payment on this issue:

  • Issue reporter: @gadhiyamanan $50, to pay via Upwork (Please accept Upwork offer)
  • Contributor: @ZhenjaHorbach $750 ($500+$750 bonus), to pay via Upwork - PAID
  • Contributor+: @mollfpr $750 ($500+$750 bonus), please request via NewDot

Upwork job is here, 50% bonus is included on final payout

@melvin-bot melvin-bot bot removed the Overdue label Oct 30, 2023
@gadhiyamanan
Copy link
Contributor

@stephanieelliott offer accepted, thanks!

@stephanieelliott
Copy link
Contributor

All Upwork payments completed!

@JmillsExpensify
Copy link

$750 payment approved for @mollfpr based on summary above.

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
None yet
Development

No branches or pull requests

8 participants