Skip to content

[$250] Room - Members number does not update in real time when user rejoin the room #43293

Closed

Description

@lanitochka17

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.80-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): gocemate+a178@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Create room> Invite a member
  2. Leave the room
  3. Open the room again> Join
  4. Go to header to open details page
  5. Take a look at members section

Expected Result:

Members number should update since there is a new member in the room

Actual Result:

Members number does not update in real time when user rejoin the room. User must open Members page to update the info

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

Bug6505057_1717768640574.Recording__3142.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017450de92e982e995
  • Upwork Job ID: 1799947003320904058
  • Last Price Increase: 2024-06-09
  • Automatic offers:
    • dominictb | Contributor | 102720197
Issue OwnerCurrent Issue Owner: @allroundexperts

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 7, 2024
  2. melvin-bot commented on Jun 7, 2024

    @melvin-bot

    Triggered auto assignment to @VictoriaExpensify (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. lanitochka17 commented on Jun 7, 2024

    @lanitochka17
    Author

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

  4. jainilparikh commented on Jun 7, 2024

    @jainilparikh

    Proposal

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

    Member count is not immediately updated when the User re-joins the chat. It is updated after the user clicks on 'Members' button.

    What is the root cause of that problem?

    When we open the side-pane (Which contains Members, Settings, Private notes etc) the state of a member does not get updated from the server.

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

    Update the number of member's by calling the server using the OPEN_ROOM_MEMBERS_PAGE action in ReportDetailsPage.tsx (https://github.com/Expensify/App/blob/main/src/pages/ReportDetailsPage.tsx) class by adding the following code:

    
        const getRoomMembers = useCallback(() => {
            if (!report) {
                return;
            }
            Report.openRoomMembersPage(report.reportID);
        }, [report]);
    
        useEffect(() => {
            getRoomMembers();
            // eslint-disable-next-line react-hooks/exhaustive-deps
        }, []);
    
    

    What alternative solutions did you explore? (Optional)

    Since, RoomMemberPage is using the same function, create this function in a common file so both classes can use it.

    Verified that the above solution updates the member count appropriately.

    Video:

    screen-recording-2024-06-08-at-35138-pm_BWW7Ctyh.mp4
  5. jainilparikh commented on Jun 8, 2024

    @jainilparikh
  6. Tony-MK commented on Jun 9, 2024

    @Tony-MK
    Contributor

    Proposal

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

    Room - Members number does not update in real time when user rejoin the room

    What is the root cause of that problem?

    The joinRoom function is not consistent with the inviteToRoom function.

    Therefore, the inviteToRoom function adds the new participant to the report.participants array.

    Unlike when joining a room, when the getVisibleChatMemberAccountIDs function is called, it has one less participant in the report.participants array

    const participants = useMemo(() => {
    if (isGroupChat) {
    return ReportUtils.getParticipantAccountIDs(report.reportID ?? '');
    }
    if (isSystemChat) {
    return ReportUtils.getParticipantAccountIDs(report.reportID ?? '').filter((accountID) => accountID !== session?.accountID);
    }
    return ReportUtils.getVisibleChatMemberAccountIDs(report.reportID ?? '');
    }, [report, session, isGroupChat, isSystemChat]);

    The report.participants array won't be updated in real-time because the front end has not been synced with the backend.

    Therefore, there will also be one less active member of the room.

    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 : [];
    });

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

    Let's make the joinRoom function consistent with the inviteToRoom function by optimistically adding the new participant before updating its notification preference.

    Similar to the inviteToRoom function, this change helps with the expected offline behavior.

    We can do this by replicating and modifying the code below to be suited for the joinRoom function.

    App/src/libs/actions/Report.ts

    Lines 2718 to 2729 in f3bb5a5

    const optimisticData: OnyxUpdate[] = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
    value: {
    participants: participantsAfterInvitation,
    pendingChatMembers,
    },
    },
    ...newPersonalDetailsOnyxData.optimisticData,
    ];

  7. VictoriaExpensify commented on Jun 9, 2024

    @VictoriaExpensify
    Contributor

    Keeping this as a low priority and adding it to the #vip_vsb project

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 9, 2024
  9. melvin-bot commented on Jun 9, 2024

    @melvin-bot
  10. changed the title [-]Room - Members number does not update in real time when user rejoin the room[/-] [+][$250] Room - Members number does not update in real time when user rejoin the room[/+] on Jun 9, 2024
  11. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 9, 2024
  12. 15 remaining items

  13. allroundexperts commented on Jun 16, 2024

    @allroundexperts
    Contributor

    @allroundexperts , I believe handling offline case was an edge case for the solution that I had proposed and IMHO, this should have been covered as part of our PR discussion. I had already done the hard work on identifying the root-cause and proposing the right solution for it.

    Most of @dominictb 's solution is based on the findings and solution (Toggling the hidden flag) that I had posted above with the slight change that it handles the offline case.

    CC: @iwiznia / @VictoriaExpensify let me know your thoughts on the same.

    @jainilparikh I don't think that the offline flow is an "edge case". Your solution seems to be different from what the selected proposal mentioned as well.

  14. dominictb commented on Jun 17, 2024

    @dominictb
    Contributor

    PR should be up for review in a few hours.

  15. melvin-bot commented on Jul 10, 2024

    @melvin-bot

    This issue has not been updated in over 15 days. @iwiznia, @allroundexperts, @VictoriaExpensify, @dominictb 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!

  16. dominictb commented on Aug 23, 2024

    @dominictb
    Contributor

    This should be ready for payment, no?

  17. melvin-bot commented on Sep 6, 2024

    @melvin-bot

    @iwiznia, @allroundexperts, @VictoriaExpensify, @dominictb, this Monthly task hasn't been acted upon in 6 weeks; closing.

    If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.

  18. allroundexperts commented on Sep 9, 2024

    @allroundexperts
    Contributor

    @VictoriaExpensify This is still pending payment.

  19. VictoriaExpensify commented on Sep 9, 2024

    @VictoriaExpensify
    Contributor

    Payment Summary:
    Contributor: @dominictb paid $250 via Upwork
    Contributor+: @allroundexperts owed $250 via NewDot

    Thanks for your work on this!

  20. JmillsExpensify commented on Oct 8, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @allroundexperts

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorMonthlyKSv2Not a priorityReviewingHas a PR in review

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions