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-06-13] [$250] mWeb - Members - When last member leaves the group, user is not prompted with a warning message #42204

Closed
1 of 6 tasks
lanitochka17 opened this issue May 15, 2024 · 26 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 May 15, 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.74
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/4566310
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/home

  2. Tap start chat

  3. Select a user and create group

  4. Send few messages

  5. Tap header -- member

  6. Select one member listed and remove the member

  7. Tap back

  8. Tap Leave group

Expected Result:

When last member leaves the group, user must be prompted with a warning message

Actual Result:

When last member leaves the group, user is not prompted with a warning message

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

Bug6481922_1715795982090.group.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0108d139f0fc936c57
  • Upwork Job ID: 1790901683068096512
  • Last Price Increase: 2024-05-16
  • Automatic offers:
    • tienifr | Contributor | 0
Issue OwnerCurrent Issue Owner: @greg-schroeder
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 15, 2024
Copy link

melvin-bot bot commented May 15, 2024

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

@lanitochka17
Copy link
Author

@greg-schroeder 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

@lanitochka17
Copy link
Author

We think that this bug might be related to #vip-vsp

@cretadn22
Copy link
Contributor

cretadn22 commented May 15, 2024

Proposal

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

When the final member leaves from the group, the user won't receive a warning message

To see this bug clearly, we can do these steps:

  1. Create a group (1 admin, 1 member)
  2. Go offline
  3. Delete the member
  4. Leave group

What is the root cause of that problem?

The issue arises because when removing the member, we only add the "pending" field and remain report.participant, but
we solely rely on report.participant to determine if it's the last member

if (Object.keys(report?.participants ?? {}).length === 1) {

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

We must ensure that we don't include members with pending deletion actions when verifying if they are the last member

if (Object.keys(report?.participants ?? {}).length - pendingChatMembers.length === 1 ) {

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@ZhenjaHorbach
Copy link
Contributor

ZhenjaHorbach commented May 15, 2024

Actually we have a ticket where we need to refactor Details page and move leave button to menu items
#40256

So I think it's better to fix this issue it there since this button will be moved to ReportDetails

And to fix this issue

Proposal

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

mWeb - Members - When last member leaves the group, user is not prompted with a warning message

What is the root cause of that problem?

The main problem with issue is that when we remove member it remains in report?.participants but with pending action equal to delete

if (Object.keys(report?.participants ?? {}).length === 1) {

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

To fix this issue we can use activeChatMembers

const activeChatMembers = participants.flatMap((accountID) => {
const pendingMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString());
return !pendingMember || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? accountID : [];
});

instead report?.participants

if (Object.keys(report?.participants ?? {}).length === 1) {

What alternative solutions did you explore? (Optional)

NA

@greg-schroeder
Copy link
Contributor

Checking if we should handle here before applying External

@greg-schroeder
Copy link
Contributor

Looks like they want to solve this separately, so let's keep it here. Going to add External

@greg-schroeder greg-schroeder added the External Added to denote the issue can be worked on by a contributor label May 16, 2024
Copy link

melvin-bot bot commented May 16, 2024

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

@melvin-bot melvin-bot bot changed the title mWeb - Members - When last member leaves the group, user is not prompted with a warning message [$250] mWeb - Members - When last member leaves the group, user is not prompted with a warning message May 16, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 16, 2024
Copy link

melvin-bot bot commented May 16, 2024

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

@tienifr
Copy link
Contributor

tienifr commented May 16, 2024

Proposal

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

When last member leaves the group, user is not prompted with a warning message

What is the root cause of that problem?

  1. In here, we're not filtering out only the active members (that are not pending delete), so even though a member is pending delete, that member is still counted in the participants length and the warning modal is not shown.

  2. Due to the same root cause, right after deleting a user, we won't be able to invite that user into the room again, the error "{user} is already a member of {workspace}" will show, even though the mentioned user was already deleted

It's because in here, we're getting the list of all participants account ids including the members that are already (pending) deleted.

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

  1. Update this method to have a new includeOnlyActiveMembers, default to false

If includeOnlyActiveMembers is true, filter out all the pending delete members here

const accountIDStrings = Object.keys(report.participants).filter((accountID) => {
    if (!includeOnlyActiveMembers) {
        return true;
    }
    const pendingMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString());
    return !pendingMember || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
});

In here, use getParticipantAccountIDs with includeOnlyActiveMembers true to get the correct account ids list, and use the length of it instead

a. In here, also pass includeOnlyActiveMembers true to getParticipantAccountIDs

After this fix, we'll face the issue where in offline mode, we delete the user, then add the same user, then go online, although the user was successfully added, they will not show up in the members list.

That's because the logic to reset the pendingChatMembers when adding members here is wrong.

b. Let's say the pendingChatMembers list is currently [delete user A, add user A], after the add user A is successful, the pendingChatMembers will be reset to [delete user A] which is incorrect because the delete user A operation was already successful before add user A is called.

To fix this we need to remove the pending delete of the same user in pendingChatMembers before setting it to successData and failureData

What alternative solutions did you explore? (Optional)

In b, we can optionally remove all pending actions of the same user pendingChatMembers rather than just the pending delete. Or even more precise is to use an Onyx response processor and remove the pending action of the latest report?. pendingChatMembers at the time the request is successful, instead of assuming the pendingChatMembers list at the time of enqueuing the inviteToRoom request.

A potential refactoring to consider:
We can remove the activeChatMembers here, and just need to pass includeOnlyActiveMembers as true here, and introduce the same prop to getVisibleChatMemberAccountIDs, and pass it as true to getVisibleChatMemberAccountIDs. That way, we'll have the correct list of participants from the start

@mananjadhav
Copy link
Collaborator

Overall all proposals have similar ideas on fixing this, but I found @tienifr's proposal comprehensive.

🎀 👀 🎀 C+ reviewed.

Copy link

melvin-bot bot commented May 16, 2024

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

Copy link

melvin-bot bot commented May 20, 2024

@mananjadhav, @dangrous, @greg-schroeder Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label May 20, 2024
@mananjadhav
Copy link
Collaborator

@dangrous quick bump

@melvin-bot melvin-bot bot removed the Overdue label May 21, 2024
@greg-schroeder
Copy link
Contributor

Thanks @mananjadhav you were 3 minutes ahead of me!

@dangrous
Copy link
Contributor

Thanks for your patience! I'm still on my 40% schedule so a bit slow. I agree with @mananjadhav's assessment, assigning to @tienifr!

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label May 22, 2024
Copy link

melvin-bot bot commented May 22, 2024

📣 @tienifr 🎉 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 📖

@tienifr
Copy link
Contributor

tienifr commented May 24, 2024

@mananjadhav PR #42512 can be reviewed

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 6, 2024
@melvin-bot melvin-bot bot changed the title [$250] mWeb - Members - When last member leaves the group, user is not prompted with a warning message [HOLD for payment 2024-06-13] [$250] mWeb - Members - When last member leaves the group, user is not prompted with a warning message Jun 6, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

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

Copy link

melvin-bot bot commented Jun 6, 2024

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

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

Copy link

melvin-bot bot commented Jun 6, 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:

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

@mananjadhav
Copy link
Collaborator

I couldn't pinpoint to the exact PR for this one, but I feel we should add a regression test for this one. The test steps from the PR looks fine to me.

  1. Open app
  2. Tap start chat
  3. Select a user and create group
  4. Send few messages
  5. Tap header -- member
  6. Select one member listed and remove the member
  7. Tap back
  8. Tap Leave group
  9. When last member leaves the group, user must be prompted with a warning message.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 12, 2024
@greg-schroeder
Copy link
Contributor

Processing

@greg-schroeder
Copy link
Contributor

Payment summary:

Contributor: @tienifr - $250 - Paid via Upwork
C+: @mananjadhav - $250 - You can make a manual request

@greg-schroeder
Copy link
Contributor

Regression test filed, closing

@JmillsExpensify
Copy link

$250 approved for @mananjadhav

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

8 participants