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

Closed

Description

@IuliiaHerets

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: 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

Activity

  1. added
    Bug
    Daily
    on Apr 1, 2025
  2. melvin-bot commented on Apr 1, 2025

    @melvin-bot

    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.

  3. daledah commented on Apr 1, 2025

    @daledah
    Contributor

    🚨 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)

  4. codewaseem commented on Apr 1, 2025

    @codewaseem
    Contributor

    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

  5. daledah commented on Apr 1, 2025

    @daledah
    Contributor

    Proposal updated

    • Included a detailed code snippet to make the proposed changes easier to review and test.
  6. huult commented on Apr 1, 2025

    @huult
    Contributor

    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.

  7. trjExpensify commented on Apr 2, 2025

    @trjExpensify
    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.

  8. dubielzyk-expensify commented on Apr 2, 2025

    @dubielzyk-expensify
    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

  9. shawnborton commented on Apr 2, 2025

    @shawnborton
    Contributor

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

  10. dannymcclain commented on Apr 2, 2025

    @dannymcclain
    Contributor

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

  11. huult commented on Apr 2, 2025

    @huult
    Contributor

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

  12. daledah commented on Apr 2, 2025

    @daledah
    Contributor

    @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.
  13. dannymcclain commented on Apr 2, 2025

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

  14. 37 remaining items

  15. melvin-bot commented on May 7, 2025

    @melvin-bot

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

  16. added
    Weekly
    and removed
    Weekly
    on May 7, 2025
  17. 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[/+] on May 7, 2025
  18. melvin-bot commented on May 7, 2025

    @melvin-bot

    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:

  19. melvin-bot commented on May 7, 2025

    @melvin-bot

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

  20. s77rt commented on May 12, 2025

    @s77rt
    Member

    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

  21. added
    Daily
    and removed
    Weekly
    on May 13, 2025
  22. trjExpensify commented on May 14, 2025

    @trjExpensify
    Contributor

    Confirming there was one regression here?

  23. trjExpensify commented on May 15, 2025

    @trjExpensify
    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!

  24. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson May 15, 2025
  25. JmillsExpensify commented on May 22, 2025

    @JmillsExpensify
    Contributor

    $75 approved for @s77rt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions