Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1472,8 +1472,8 @@ function createOptionList(personalDetails: OnyxEntry<PersonalDetailsList>, repor
}

const isSelfDM = ReportUtils.isSelfDM(report);
// Currently, currentUser is not included in visibleChatMemberAccountIDs, so for selfDM we need to add the currentUser as participants.
const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.visibleChatMemberAccountIDs ?? [];
// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is causing a regression here #41138.

Because createOption relies on personalDetailList.length > 1, which is not true for DM's when using participants, since the participants property has everyone in that conversation including the current user.

This also makes the above comment wrongish, for some reason the currentUser is not included as a participant in the selfDM but is included in other chats.


if (!accountIDs || accountIDs.length === 0) {
return;
Expand Down Expand Up @@ -1692,8 +1692,8 @@ function getOptions(
const isPolicyExpenseChat = option.isPolicyExpenseChat;
const isMoneyRequestReport = option.isMoneyRequestReport;
const isSelfDM = option.isSelfDM;
// Currently, currentUser is not included in visibleChatMemberAccountIDs, so for selfDM we need to add the currentUser as participants.
const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.visibleChatMemberAccountIDs ?? [];
// 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);

if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) {
return;
Expand Down
10 changes: 9 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3200,6 +3200,11 @@ function createSplitsAndOnyxData(
splitChatReport.lastMessageText = splitIOUReportAction.message?.[0]?.text;
splitChatReport.lastMessageHtml = splitIOUReportAction.message?.[0]?.html;

let splitChatReportNotificationPreference = splitChatReport.notificationPreference;
if (splitChatReportNotificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) {
splitChatReportNotificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS;
}

// If we have an existing splitChatReport (group chat or workspace) use it's pending fields, otherwise indicate that we are adding a chat
if (!existingSplitChatReport) {
splitChatReport.pendingFields = {
Expand All @@ -3213,7 +3218,10 @@ function createSplitsAndOnyxData(
// and we need the data to be available when we navigate to the chat page
onyxMethod: existingSplitChatReport ? Onyx.METHOD.MERGE : Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${splitChatReport.reportID}`,
value: splitChatReport,
value: {
...splitChatReport,
notificationPreference: splitChatReportNotificationPreference,
},
},
{
onyxMethod: Onyx.METHOD.SET,
Expand Down
50 changes: 50 additions & 0 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ describe('OptionsListUtils', () => {
reportID: '1',
participantAccountIDs: [2, 1],
visibleChatMemberAccountIDs: [2, 1],
participants: {
2: {},
1: {},
},
reportName: 'Iron Man, Mister Fantastic',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -31,6 +35,9 @@ describe('OptionsListUtils', () => {
reportID: '2',
participantAccountIDs: [3],
visibleChatMemberAccountIDs: [3],
participants: {
3: {},
},
reportName: 'Spider-Man',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -43,6 +50,9 @@ describe('OptionsListUtils', () => {
reportID: '3',
participantAccountIDs: [1],
visibleChatMemberAccountIDs: [1],
participants: {
1: {},
},
reportName: 'Mister Fantastic',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -53,6 +63,9 @@ describe('OptionsListUtils', () => {
reportID: '4',
participantAccountIDs: [4],
visibleChatMemberAccountIDs: [4],
participants: {
4: {},
},
reportName: 'Black Panther',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -63,6 +76,9 @@ describe('OptionsListUtils', () => {
reportID: '5',
participantAccountIDs: [5],
visibleChatMemberAccountIDs: [5],
participants: {
5: {},
},
reportName: 'Invisible Woman',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -73,6 +89,9 @@ describe('OptionsListUtils', () => {
reportID: '6',
participantAccountIDs: [6],
visibleChatMemberAccountIDs: [6],
participants: {
6: {},
},
reportName: 'Thor',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -85,6 +104,9 @@ describe('OptionsListUtils', () => {
reportID: '7',
participantAccountIDs: [7],
visibleChatMemberAccountIDs: [7],
participants: {
7: {},
},
reportName: 'Captain America',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -97,6 +119,9 @@ describe('OptionsListUtils', () => {
reportID: '8',
participantAccountIDs: [12],
visibleChatMemberAccountIDs: [12],
participants: {
12: {},
},
reportName: 'Silver Surfer',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -109,6 +134,9 @@ describe('OptionsListUtils', () => {
reportID: '9',
participantAccountIDs: [8],
visibleChatMemberAccountIDs: [8],
participants: {
8: {},
},
reportName: 'Mister Sinister',
iouReportID: '100',
type: CONST.REPORT.TYPE.CHAT,
Expand All @@ -122,6 +150,10 @@ describe('OptionsListUtils', () => {
isPinned: false,
participantAccountIDs: [2, 7],
visibleChatMemberAccountIDs: [2, 7],
participants: {
2: {},
7: {},
},
reportName: '',
oldPolicyName: "SHIELD's workspace",
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
Expand Down Expand Up @@ -212,6 +244,9 @@ describe('OptionsListUtils', () => {
reportID: '11',
participantAccountIDs: [999],
visibleChatMemberAccountIDs: [999],
participants: {
999: {},
},
reportName: 'Concierge',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -226,6 +261,9 @@ describe('OptionsListUtils', () => {
reportID: '12',
participantAccountIDs: [1000],
visibleChatMemberAccountIDs: [1000],
participants: {
1000: {},
},
reportName: 'Chronos',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -240,6 +278,9 @@ describe('OptionsListUtils', () => {
reportID: '13',
participantAccountIDs: [1001],
visibleChatMemberAccountIDs: [1001],
participants: {
1001: {},
},
reportName: 'Receipts',
type: CONST.REPORT.TYPE.CHAT,
},
Expand All @@ -254,6 +295,11 @@ describe('OptionsListUtils', () => {
reportID: '14',
participantAccountIDs: [1, 10, 3],
visibleChatMemberAccountIDs: [1, 10, 3],
participants: {
1: {},
10: {},
3: {},
},
reportName: '',
oldPolicyName: 'Avengers Room',
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS,
Expand All @@ -271,6 +317,10 @@ describe('OptionsListUtils', () => {
reportID: '15',
participantAccountIDs: [3, 4],
visibleChatMemberAccountIDs: [3, 4],
participants: {
3: {},
4: {},
},
reportName: 'Spider-Man, Black Panther',
type: CONST.REPORT.TYPE.CHAT,
chatType: CONST.REPORT.CHAT_TYPE.DOMAIN_ALL,
Expand Down