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 #36378][$500] The member list of a public room shows inconsistent results #37192

Closed
1 of 6 tasks
m-natarajan opened this issue Feb 26, 2024 · 18 comments
Closed
1 of 6 tasks
Assignees
Labels
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

@m-natarajan
Copy link

m-natarajan commented Feb 26, 2024

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: 1.4.43-14
Reproducible in staging?:
Reproducible in production?:
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
Expensify/Expensify Issue URL:
Issue reported by: @quinthar
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1708893734376029

Action Performed:

Precondition: Have a public room, users with real accounts and anonymous users without email contact information

  1. Go to the public room
  2. Click on the header to see the details of the room
  3. Look at the members count
  4. Click on the members to see the members list
  5. Go back to the details page and look at the members count

Expected Result:

Should show the same number of the members

Actual Result:

It first showing the correct number of people who have signed in with real accounts and when opening the members list and going back it includes anonymous user (who didn't provide any email contact information)

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

image (6)

image (7)

Recording.2780.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a589af5940630bea
  • Upwork Job ID: 1761932775026454528
  • Last Price Increase: 2024-02-26
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Feb 26, 2024
Copy link

melvin-bot bot commented Feb 26, 2024

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

@kadiealexander kadiealexander added the External Added to denote the issue can be worked on by a contributor label Feb 26, 2024
Copy link

melvin-bot bot commented Feb 26, 2024

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

@melvin-bot melvin-bot bot changed the title The member list of a public room shows inconsistent results [$500] The member list of a public room shows inconsistent results Feb 26, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 26, 2024
Copy link

melvin-bot bot commented Feb 26, 2024

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

@kadiealexander
Copy link
Contributor

Reproduced in chrome.

@brunovjk
Copy link
Contributor

I believe they are similar #36378

@wildan-m
Copy link
Contributor

wildan-m commented Feb 26, 2024

Proposal

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

The member list of a public room shows inconsistent results

What is the root cause of that problem?

We have not omitted any visible members without personal details on the report detail page.

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

Filter visible members with personal details in getVisibleMemberIDs

function getVisibleMemberIDs(report: OnyxEntry<Report>): number[] {
    if (!report) {
        return [];
    }
    const visibleChatMemberAccountIDs = report.visibleChatMemberAccountIDs ?? [];

    let visibleMemberIDs: number[] = [];
    report?.visibleChatMemberAccountIDs?.forEach((accountID) => {
        const details = allPersonalDetails?.[accountID];

        if (!details) {
            return;
        }

        visibleMemberIDs.push(accountID);
    });

    // Build participants list for IOU/expense reports
    if (isMoneyRequestReport(report)) {
        const onlyTruthyValues = [report.managerID, report.ownerAccountID, ...visibleChatMemberAccountIDs].filter(Boolean) as number[];
        const onlyUnique = [...new Set([...onlyTruthyValues])];
        return onlyUnique;
    }

    return visibleMemberIDs;}

Then we can modify this code to optimize loop:

const details = personalDetails[accountID];
if (!details) {
Log.hmmm(`[RoomMembersPage] no personal details found for room member with accountID: ${accountID}`);
return;
}

Modify to:

        const participants = useMemo(() => ReportUtils.getVisibleMemberIDs(report), [report]);
        participants.forEach((accountID) => {
            const details = personalDetails[accountID];

            if (!details) {
                Log.hmmm(`[RoomMembersPage] no personal details found for room member with accountID: ${accountID}`);
                return;
            }

We could also add filtering per page in ReportDetailsPage.tsx, similar to what RoomMembersPage did.

What alternative solutions did you explore? (Optional)

Do we intend to display all members, even if they do not have personal details? If so, we can omit the null check on the personalDetails data.

We can remove return and fallback null to empty object in getMemberOptions. Change

const getMemberOptions = (): ListItem[] => {
let result: ListItem[] = [];
report?.visibleChatMemberAccountIDs?.forEach((accountID) => {
const details = personalDetails[accountID];
if (!details) {
Log.hmmm(`[RoomMembersPage] no personal details found for room member with accountID: ${accountID}`);
return;
}

To:

    const getMemberOptions = (): ListItem[] => {
        let result: ListItem[] = [];

        report?.visibleChatMemberAccountIDs?.forEach((accountID) => {
            const details = personalDetails[accountID] || {} as PersonalDetails;
            if (!details) {
                Log.hmmm(`[RoomMembersPage] no personal details found for room member with accountID: ${accountID}`);
            }

It will show "Hidden" since the returned value after the invite is an empty object. I believe the room admin/owner should be able to view at least the registered contact (email/number) so they can identify the members (Require backend change). This is a suggestion for the returned object for non-registered users, it has the same structure as optimistic data.

{
    "login": "[email protected]",
    "accountID": 83056826,
    "avatar": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_3.png",
    "displayName": "[email protected]"
}

@mkhutornyi
Copy link
Contributor

I believe they are similar #36378

Agree. I think we can hold this for #36378

@Emrullah-Akbulak
Copy link

Proposal

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

Member count in a public room's details shows inconsistency when the user enters the "RoomMembersPage" and goes back to the "ReportDetailsPage".

What is the root cause of that problem?

When user opens a room the client sends an API command called "OpenReport" which returns the report information that is used to display the room's details such as member count. However, when the user navigates to "RoomMembersPage" via clicking "Members" button, the client sends another command called "OpenRoomMembersPage". This new command's response returns new object which has the following properties "participantAccountIDs", "participants", "visibleChatMemberAccountIDs", then this fields gets merged with the existing report via Onyx.

The problem is the participantAccountIDs fields between these requests "OpenReport" and "RoomMembersPage" returns different values and that causes "RoomMembersPage" command's response to override these 3 fields. When the fields get overwritten, the following code in "ReportDetailsPage"

const participants = useMemo(() => {
        console.log("I have RUN" ,report);
        return ReportUtils.getVisibleMemberIDs(report)
    }, [report]);

updates the participant count with the new overwritten values due to report object being updated by "OpenRoomMembersPage" command. Hence the member count changes when the user navigates & go backs from the "RoomMembersPage".

Moreover, the code that calls the "OpenRoomMembersPage" command is located at RoomMembersPage and wrapped in useEffect hook that runs only once the component mounts.

    const getRoomMembers = useCallback(() => {
        if (!report) {
            return;
        }
        Report.openRoomMembersPage(report.reportID);
        setDidLoadRoomMembers(true);
    }, [report]);

    useEffect(() => {
        getRoomMembers();
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [])

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

Assuming that "OpenReport" command returns the true value of the report. The "OpenRoomMembersPage" should either use the same filtration as the "OpenReport" command so that it filters and returns the same number of members to client.

What alternative solutions did you explore? (Optional)

In my opinion, the "OpenRoomMembersPage" command can also be completely removed or altered since it permanently adds the "participantAccountIDs", "participants", "visibleChatMemberAccountIDs" fields to report object for no apparent reason other then being used in "RoomMembersPage" page . I haven't checked all the code that uses these fields but if these 3 fields are only going to be added once the user enter the "RoomMembersPage " page then they should get disposed and not permanently alter the report object when the user goes back.

Copy link

melvin-bot bot commented Feb 26, 2024

📣 @Emrullah-Akbulak! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@Emrullah-Akbulak
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01565aae43960f7cbc

Copy link

melvin-bot bot commented Feb 26, 2024

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@melvin-bot melvin-bot bot added the Overdue label Feb 28, 2024
@kadiealexander kadiealexander changed the title [$500] The member list of a public room shows inconsistent results [Hold for #36378][$500] The member list of a public room shows inconsistent results Feb 28, 2024
@kadiealexander kadiealexander added Weekly KSv2 and removed Help Wanted Apply this label when an issue is open to proposals by contributors Daily KSv2 labels Feb 28, 2024
@melvin-bot melvin-bot bot removed the Overdue label Feb 28, 2024
@kadiealexander
Copy link
Contributor

Holding for #36378!

@melvin-bot melvin-bot bot added the Overdue label Mar 8, 2024
@kadiealexander
Copy link
Contributor

Still on hold.

@melvin-bot melvin-bot bot removed the Overdue label Mar 11, 2024
@melvin-bot melvin-bot bot added the Overdue label Mar 19, 2024
@kadiealexander
Copy link
Contributor

Same

@kadiealexander
Copy link
Contributor

Still on hold.

@melvin-bot melvin-bot bot removed the Overdue label Apr 2, 2024
@melvin-bot melvin-bot bot added the Overdue label Apr 10, 2024
@kadiealexander
Copy link
Contributor

Still on hold.

@kadiealexander
Copy link
Contributor

Asked for a retest here.

@melvin-bot melvin-bot bot removed the Overdue label May 14, 2024
@kadiealexander kadiealexander added Daily KSv2 and removed Monthly KSv2 labels May 14, 2024
@kbecciv
Copy link

kbecciv commented May 14, 2024

QA team is unable to reproduce it on build 1.4.74.3

Recording.477.mp4
Recording.476.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

7 participants