Skip to content

[Due for payment 2025-05-14] [Due for payment 2025-05-14] [$250] AU - Room Invite - App auto-deselects all members after returning from member details page #59426

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

Closed
8 tasks done
IuliiaHerets opened this issue Apr 1, 2025 · 36 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 Apr 1, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: v9.1.21-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5857030
Issue reported by: Applause Internal Team
Device used: Windows 10 / Chrome
App Component: Workspace Settings

Action Performed:

  1. Click 'FAB' > Start Chat > create a #Room
  2. Complete the Room details > click Create Room
  3. Click on the Room details in the new chat > Members > click Invite and
  4. Invite several test accounts to the room
  5. Click the Invite button again
  6. Now select a couple of members, click on a single member outside the checkbox area
  7. Verify the "Member Details" page opens
  8. Return to the Invite page

Expected Result:

The app should retain all selected members after opening the member details page and returning.

Actual Result:

After selecting some members, opening the member details page, and returning, all selected members are deselected.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6788705_1743498007635.Check_box_disappear.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021907487964037532418
  • Upwork Job ID: 1907487964037532418
  • Last Price Increase: 2025-04-02
  • Automatic offers:
    • daledah | Contributor | 106778879
Issue OwnerCurrent Issue Owner: @trjExpensify
@IuliiaHerets IuliiaHerets added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Apr 1, 2025
Copy link

melvin-bot bot commented Apr 1, 2025

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

@daledah
Copy link
Contributor

daledah commented Apr 1, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-04-01 10:21:47 UTC.

Proposal

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

  • After selecting some members, opening a member’s detail page, and then navigating back, all previously selected members are deselected.

What is the root cause of that problem?

  • This logic clears the selected options whenever the screen loses focus, which causes all selected members to be reset upon navigating away and returning.

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

  • We should remove the logic that clears selected members on screen blur.
  • Instead, we should introduce logic to automatically update the selection only when a selected user has been removed from the room.
  • We already have similar logic in place for auto-updating selections in the WorkspaceCategoriesPage, which we can use as a reference and adapt for the RoomMembersPage.
  • Below is a basic example of the proposed change. The implementation details can be refined during the PR:
    useEffect(() => {
        if (selectedMembers.length === 0 || !canSelectMultiple) {
            return;
        }
    
        setSelectedMembers((prevSelectedMembers) => {
            const updatedSelectedMembers = prevSelectedMembers.filter((accountID) => {
                const isInParticipants = participants.includes(accountID);
                const pendingChatMember = reportMetadata?.pendingChatMembers?.findLast(
                    (member) => member.accountID === accountID.toString(),
                );
    
                const isPendingDelete = pendingChatMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
    
                // Keep the member only if they're still in the room and not pending removal
                return isInParticipants && !isPendingDelete;
            });
    
            return updatedSelectedMembers;
        });
    }, [participants, reportMetadata?.pendingChatMembers, canSelectMultiple, selectedMembers.length]);
  • We should apply the same approach across other pages to ensure consistency throughout the app.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

None

What alternative solutions did you explore? (Optional)

@codewaseem
Copy link
Contributor

codewaseem commented Apr 1, 2025

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

When a user is removed from a room via the RoomMemberDetailsPage, the selected members count in RoomMembersPage becomes incorrect because the selectedMembers state is not being updated to reflect the removed user.

What is the root cause of that problem?

The following code resets the selected members when screen is not focused.

useEffect(() => {
if (isFocusedScreen) {
return;
}
setSelectedMembers([]);
}, [isFocusedScreen]);

It was added to handle the button count reset upon member deletion.

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

Delete the above logic. Update the selected members' count, if they are deleted on the member's details page.

 const participants = useMemo(() => getParticipantsList(report, personalDetails, true), [report, personalDetails, isFocusedScreen]);

useEffect(() => {
        // Remove any selected members that are no longer in the participants list
        setSelectedMembers((prevSelected) => prevSelected.filter((selectedId) => participants.includes(selectedId)));
    }, [participants]);

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

What alternative solutions did you explore? (Optional)

N/A

@daledah
Copy link
Contributor

daledah commented Apr 1, 2025

Proposal updated

  • Included a detailed code snippet to make the proposed changes easier to review and test.

@huult
Copy link
Contributor

huult commented Apr 1, 2025

Proposal

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

App auto-deselects all members after returning from member details page

What is the root cause of that problem?

We set selectedMembers to an empty array when opening the room member details page, so when we navigate back, the selection is cleared. This behavior is confirmed in PR #48806

setSelectedMembers([]);

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

To resolve this issue, we just need to set selectedMembers to an empty array when a member is deleted

1 Remove this hook

useEffect(() => {
if (isFocusedScreen) {
return;
}
setSelectedMembers([]);
}, [isFocusedScreen]);

2 Add new logic to handle selectedMembers to an empty array

add:

    useEffect(() => {
        const shouldClearSelection = selectedMembers.some((accountID) => {
            const pendingChatMember = reportMetadata?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString());

            return pendingChatMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
        });

        if (shouldClearSelection) {
            setSelectedMembers([]);
        }
    }, [reportMetadata?.pendingChatMembers, selectedMembers]);

expected of PR #48806

Expected Result on desktop: The dropdown button gets replaced with the green "+ Invite member" button and none of the members remain selected
Expected Result on mobile: The dropdown button "Selected" count is reset to 0 and none of the members remain selected. The mobile selection mode is still enabled.
Screen.Recording.2025-04-01.at.23.07.01.mp4

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

None

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.

@trjExpensify
Copy link
Contributor

@Expensify/design I'm cool with this change to persist the selection here? But I've noticed some inconsistencies, so wanted to double check ya'll are cool with this too? I.e Distance rates and Members table in workspace settings don't persist on selection, but Categories and Taxes do.

I think we should require a full sweep here through the app to make it consistent whichever way we go.

@dubielzyk-expensify
Copy link
Contributor

Yeah, I like the idea of making it persistent all over the app. We have the same on the reports page where you can multi-select, but open an expense and close again. I think that's the desired UX

@shawnborton
Copy link
Contributor

Definitely agree with that, let's fix this and make it consistent everywhere.

@dannymcclain
Copy link
Contributor

+1 from me as well. Let's make it work the same everywhere.

@huult
Copy link
Contributor

huult commented Apr 2, 2025

@trjExpensify @dannymcclain When we remove a member, should we persist the selection or reset it as I proposed?

@daledah
Copy link
Contributor

daledah commented Apr 2, 2025

@trjExpensify @dannymcclain I believe the behavior in the category page should serve as the source of truth for this implementation, as it offers several key advantages:

  1. Selection persistence – The chosen categories remain intact even when users navigate away and return.
  2. Automatic updates – If a selected category is deleted (by another device or an admin), the list updates accordingly.

In contrast, the current room member page behavior has limitations:

  1. Selection reset – Selections are cleared whenever users navigate elsewhere.
  2. No live updates – If a selected member is removed (by another device or admin), the changes aren’t reflected automatically.

@dannymcclain
Copy link
Contributor

Yeah I tend to agree with @daledah's suggestion of using categories as the source of truth.

@huult this is how categories currently works—is this helpful?

CleanShot.2025-04-02.at.11.29.59.mp4

cc @Expensify/design

@shawnborton
Copy link
Contributor

Yeah, that feels right to me 👍

@huult
Copy link
Contributor

huult commented Apr 2, 2025

Yes, but I think we should be consistent in the same case.

@trjExpensify trjExpensify added the External Added to denote the issue can be worked on by a contributor label Apr 2, 2025
Copy link

melvin-bot bot commented Apr 2, 2025

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

@melvin-bot melvin-bot bot changed the title AU - Room Invite - App auto-deselects all members after returning from member details page [$250] AU - Room Invite - App auto-deselects all members after returning from member details page Apr 2, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 2, 2025
Copy link

melvin-bot bot commented Apr 2, 2025

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

@trjExpensify trjExpensify moved this to Bugs and Follow Up Issues in #expensify-bugs Apr 2, 2025
@s77rt
Copy link
Contributor

s77rt commented Apr 2, 2025

@daledah Thanks for the proposal. The RCA makes sense and the solution overall looks good to me.

🎀 👀 🎀 C+ reviewed
Link to proposal

Copy link

melvin-bot bot commented Apr 2, 2025

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

@s77rt
Copy link
Contributor

s77rt commented Apr 2, 2025

@codewaseem Thanks for the proposal. RCA is correct but I think the solution is same as @daledah suggested.

@s77rt
Copy link
Contributor

s77rt commented Apr 2, 2025

@huult Thanks for the proposal. The root cause is correct but the solution does not align with the expected behaviour i.e. we shouldn't clear the selection.

@melvin-bot melvin-bot bot added the Monthly KSv2 label Apr 28, 2025
Copy link

melvin-bot bot commented Apr 28, 2025

This issue has not been updated in over 15 days. @trjExpensify, @s77rt, @mountiny, @daledah eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@s77rt
Copy link
Contributor

s77rt commented Apr 28, 2025

PR still under review

Copy link

melvin-bot bot commented May 6, 2025

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 7, 2025
@melvin-bot melvin-bot bot changed the title [$250] AU - Room Invite - App auto-deselects all members after returning from member details page [Due for payment 2025-05-14] [$250] AU - Room Invite - App auto-deselects all members after returning from member details page May 7, 2025
Copy link

melvin-bot bot commented May 7, 2025

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 7, 2025
Copy link

melvin-bot bot commented May 7, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.40-7 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 2025-05-14. 🎊

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

Copy link

melvin-bot bot commented May 7, 2025

@s77rt @trjExpensify @s77rt 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 Weekly KSv2 and removed Weekly KSv2 labels May 7, 2025
@melvin-bot melvin-bot bot changed the title [Due for payment 2025-05-14] [$250] AU - Room Invite - App auto-deselects all members after returning from member details page [Due for payment 2025-05-14] [Due for payment 2025-05-14] [$250] AU - Room Invite - App auto-deselects all members after returning from member details page May 7, 2025
Copy link

melvin-bot bot commented May 7, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.41-1 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 2025-05-14. 🎊

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

Copy link

melvin-bot bot commented May 7, 2025

@s77rt @trjExpensify @s77rt 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]

@s77rt s77rt mentioned this issue May 12, 2025
50 tasks
@s77rt
Copy link
Contributor

s77rt commented May 12, 2025

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 (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 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: [CP Staging] Fix/48801 #48806 (comment)

  • [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: n/a

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

    Bug requires regression test: No, given that this is coming from a testrail test already I don't think an explicit test is needed

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 13, 2025
@trjExpensify
Copy link
Contributor

Confirming there was one regression here?

@trjExpensify
Copy link
Contributor

Okay cool, confirming payment as follows:

  • $75 to @s77rt for the C+ review (go ahead and request)
  • $75 to @daledah for the PR (paid!)

Thanks, closing!

@github-project-automation github-project-automation bot moved this from Bugs and Follow Up Issues to Done in #expensify-bugs May 15, 2025
@JmillsExpensify
Copy link

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

No branches or pull requests