From 694873fe49b9a0ba943e185d412c742ce8c10a08 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 30 Apr 2024 00:36:04 +0800 Subject: [PATCH 1/3] filter out current user --- src/libs/OptionsListUtils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 8166036e8e17..db6b8d2fbcb0 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1455,8 +1455,8 @@ function createOptionList(personalDetails: OnyxEntry, repor } const isSelfDM = ReportUtils.isSelfDM(report); - // Currently, currentUser is not included in participants, so for selfDM we need to add the currentUser as participants. - const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number); + // For selfDM we need to add the currentUser as participants. + const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number).filter(accountID => accountID !== currentUserAccountID); if (!accountIDs || accountIDs.length === 0) { return; @@ -1676,8 +1676,8 @@ function getOptions( const isPolicyExpenseChat = option.isPolicyExpenseChat; const isMoneyRequestReport = option.isMoneyRequestReport; const isSelfDM = option.isSelfDM; - // Currently, currentUser is not included in participants, so for selfDM we need to add the currentUser as participants. - const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number); + // For selfDM we need to add the currentUser as participants. + const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number).filter(accountID => accountID !== currentUserAccountID); if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) { return; From cd1d9b9bbe61822043fa20270a7da5f765e8c1fc Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 30 Apr 2024 22:25:06 +0800 Subject: [PATCH 2/3] filter out current user for 1:1 chat only --- src/libs/OptionsListUtils.ts | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index db6b8d2fbcb0..462845f2d83b 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1455,8 +1455,18 @@ function createOptionList(personalDetails: OnyxEntry, repor } const isSelfDM = ReportUtils.isSelfDM(report); - // For selfDM we need to add the currentUser as participants. - const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number).filter(accountID => accountID !== currentUserAccountID); + let accountIDs = []; + + if (isSelfDM) { + // For selfDM we need to add the currentUser as participants. + accountIDs = [currentUserAccountID ?? 0]; + } else { + accountIDs = Object.keys(report.participants ?? {}).map(Number); + if (ReportUtils.isOneOnOneChat(report)) { + // For 1:1 chat, we don't want to include currentUser as participants + accountIDs = accountIDs.filter(accountID => accountID !== currentUserAccountID); + } + } if (!accountIDs || accountIDs.length === 0) { return; @@ -1676,8 +1686,18 @@ function getOptions( const isPolicyExpenseChat = option.isPolicyExpenseChat; const isMoneyRequestReport = option.isMoneyRequestReport; const isSelfDM = option.isSelfDM; - // For selfDM we need to add the currentUser as participants. - const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number).filter(accountID => accountID !== currentUserAccountID); + let accountIDs = []; + + if (isSelfDM) { + // For selfDM we need to add the currentUser as participants. + accountIDs = [currentUserAccountID ?? 0]; + } else { + accountIDs = Object.keys(report.participants ?? {}).map(Number); + if (ReportUtils.isOneOnOneChat(report)) { + // For 1:1 chat, we don't want to include currentUser as participants + accountIDs = accountIDs.filter(accountID => accountID !== currentUserAccountID); + } + } if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) { return; From 9e70a0aa9c41b15e97b5ef80526bf5daef36e285 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 30 Apr 2024 22:52:49 +0800 Subject: [PATCH 3/3] prettier and update comment --- src/libs/OptionsListUtils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 462845f2d83b..288848adeb3a 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1463,8 +1463,8 @@ function createOptionList(personalDetails: OnyxEntry, repor } else { accountIDs = Object.keys(report.participants ?? {}).map(Number); if (ReportUtils.isOneOnOneChat(report)) { - // For 1:1 chat, we don't want to include currentUser as participants - accountIDs = accountIDs.filter(accountID => accountID !== currentUserAccountID); + // For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants + accountIDs = accountIDs.filter((accountID) => accountID !== currentUserAccountID); } } @@ -1694,8 +1694,8 @@ function getOptions( } else { accountIDs = Object.keys(report.participants ?? {}).map(Number); if (ReportUtils.isOneOnOneChat(report)) { - // For 1:1 chat, we don't want to include currentUser as participants - accountIDs = accountIDs.filter(accountID => accountID !== currentUserAccountID); + // For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants + accountIDs = accountIDs.filter((accountID) => accountID !== currentUserAccountID); } }