Skip to content

Commit 34434a5

Browse files
authored
Merge pull request #40271 from bernhardoj/fix/37519-group-chat-not-show-in-search-after-split
Fix group chat isn't shows in search page after split
2 parents 1b3301b + 2f8983d commit 34434a5

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

src/libs/OptionsListUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,8 @@ function createOptionList(personalDetails: OnyxEntry<PersonalDetailsList>, repor
14671467
}
14681468

14691469
const isSelfDM = ReportUtils.isSelfDM(report);
1470-
// Currently, currentUser is not included in visibleChatMemberAccountIDs, so for selfDM we need to add the currentUser as participants.
1471-
const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.visibleChatMemberAccountIDs ?? [];
1470+
// Currently, currentUser is not included in participants, so for selfDM we need to add the currentUser as participants.
1471+
const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number);
14721472

14731473
if (!accountIDs || accountIDs.length === 0) {
14741474
return;
@@ -1688,8 +1688,8 @@ function getOptions(
16881688
const isPolicyExpenseChat = option.isPolicyExpenseChat;
16891689
const isMoneyRequestReport = option.isMoneyRequestReport;
16901690
const isSelfDM = option.isSelfDM;
1691-
// Currently, currentUser is not included in visibleChatMemberAccountIDs, so for selfDM we need to add the currentUser as participants.
1692-
const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.visibleChatMemberAccountIDs ?? [];
1691+
// Currently, currentUser is not included in participants, so for selfDM we need to add the currentUser as participants.
1692+
const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number);
16931693

16941694
if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) {
16951695
return;

src/libs/actions/IOU.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3167,6 +3167,11 @@ function createSplitsAndOnyxData(
31673167
splitChatReport.lastMessageText = splitIOUReportAction.message?.[0]?.text;
31683168
splitChatReport.lastMessageHtml = splitIOUReportAction.message?.[0]?.html;
31693169

3170+
let splitChatReportNotificationPreference = splitChatReport.notificationPreference;
3171+
if (splitChatReportNotificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) {
3172+
splitChatReportNotificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS;
3173+
}
3174+
31703175
// If we have an existing splitChatReport (group chat or workspace) use it's pending fields, otherwise indicate that we are adding a chat
31713176
if (!existingSplitChatReport) {
31723177
splitChatReport.pendingFields = {
@@ -3180,7 +3185,10 @@ function createSplitsAndOnyxData(
31803185
// and we need the data to be available when we navigate to the chat page
31813186
onyxMethod: existingSplitChatReport ? Onyx.METHOD.MERGE : Onyx.METHOD.SET,
31823187
key: `${ONYXKEYS.COLLECTION.REPORT}${splitChatReport.reportID}`,
3183-
value: splitChatReport,
3188+
value: {
3189+
...splitChatReport,
3190+
notificationPreference: splitChatReportNotificationPreference,
3191+
},
31843192
},
31853193
{
31863194
onyxMethod: Onyx.METHOD.SET,

tests/unit/OptionsListUtilsTest.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ describe('OptionsListUtils', () => {
2121
reportID: '1',
2222
participantAccountIDs: [2, 1],
2323
visibleChatMemberAccountIDs: [2, 1],
24+
participants: {
25+
2: {},
26+
1: {},
27+
},
2428
reportName: 'Iron Man, Mister Fantastic',
2529
type: CONST.REPORT.TYPE.CHAT,
2630
},
@@ -31,6 +35,9 @@ describe('OptionsListUtils', () => {
3135
reportID: '2',
3236
participantAccountIDs: [3],
3337
visibleChatMemberAccountIDs: [3],
38+
participants: {
39+
3: {},
40+
},
3441
reportName: 'Spider-Man',
3542
type: CONST.REPORT.TYPE.CHAT,
3643
},
@@ -43,6 +50,9 @@ describe('OptionsListUtils', () => {
4350
reportID: '3',
4451
participantAccountIDs: [1],
4552
visibleChatMemberAccountIDs: [1],
53+
participants: {
54+
1: {},
55+
},
4656
reportName: 'Mister Fantastic',
4757
type: CONST.REPORT.TYPE.CHAT,
4858
},
@@ -53,6 +63,9 @@ describe('OptionsListUtils', () => {
5363
reportID: '4',
5464
participantAccountIDs: [4],
5565
visibleChatMemberAccountIDs: [4],
66+
participants: {
67+
4: {},
68+
},
5669
reportName: 'Black Panther',
5770
type: CONST.REPORT.TYPE.CHAT,
5871
},
@@ -63,6 +76,9 @@ describe('OptionsListUtils', () => {
6376
reportID: '5',
6477
participantAccountIDs: [5],
6578
visibleChatMemberAccountIDs: [5],
79+
participants: {
80+
5: {},
81+
},
6682
reportName: 'Invisible Woman',
6783
type: CONST.REPORT.TYPE.CHAT,
6884
},
@@ -73,6 +89,9 @@ describe('OptionsListUtils', () => {
7389
reportID: '6',
7490
participantAccountIDs: [6],
7591
visibleChatMemberAccountIDs: [6],
92+
participants: {
93+
6: {},
94+
},
7695
reportName: 'Thor',
7796
type: CONST.REPORT.TYPE.CHAT,
7897
},
@@ -85,6 +104,9 @@ describe('OptionsListUtils', () => {
85104
reportID: '7',
86105
participantAccountIDs: [7],
87106
visibleChatMemberAccountIDs: [7],
107+
participants: {
108+
7: {},
109+
},
88110
reportName: 'Captain America',
89111
type: CONST.REPORT.TYPE.CHAT,
90112
},
@@ -97,6 +119,9 @@ describe('OptionsListUtils', () => {
97119
reportID: '8',
98120
participantAccountIDs: [12],
99121
visibleChatMemberAccountIDs: [12],
122+
participants: {
123+
12: {},
124+
},
100125
reportName: 'Silver Surfer',
101126
type: CONST.REPORT.TYPE.CHAT,
102127
},
@@ -109,6 +134,9 @@ describe('OptionsListUtils', () => {
109134
reportID: '9',
110135
participantAccountIDs: [8],
111136
visibleChatMemberAccountIDs: [8],
137+
participants: {
138+
8: {},
139+
},
112140
reportName: 'Mister Sinister',
113141
iouReportID: '100',
114142
type: CONST.REPORT.TYPE.CHAT,
@@ -122,6 +150,10 @@ describe('OptionsListUtils', () => {
122150
isPinned: false,
123151
participantAccountIDs: [2, 7],
124152
visibleChatMemberAccountIDs: [2, 7],
153+
participants: {
154+
2: {},
155+
7: {},
156+
},
125157
reportName: '',
126158
oldPolicyName: "SHIELD's workspace",
127159
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
@@ -212,6 +244,9 @@ describe('OptionsListUtils', () => {
212244
reportID: '11',
213245
participantAccountIDs: [999],
214246
visibleChatMemberAccountIDs: [999],
247+
participants: {
248+
999: {},
249+
},
215250
reportName: 'Concierge',
216251
type: CONST.REPORT.TYPE.CHAT,
217252
},
@@ -226,6 +261,9 @@ describe('OptionsListUtils', () => {
226261
reportID: '12',
227262
participantAccountIDs: [1000],
228263
visibleChatMemberAccountIDs: [1000],
264+
participants: {
265+
1000: {},
266+
},
229267
reportName: 'Chronos',
230268
type: CONST.REPORT.TYPE.CHAT,
231269
},
@@ -240,6 +278,9 @@ describe('OptionsListUtils', () => {
240278
reportID: '13',
241279
participantAccountIDs: [1001],
242280
visibleChatMemberAccountIDs: [1001],
281+
participants: {
282+
1001: {},
283+
},
243284
reportName: 'Receipts',
244285
type: CONST.REPORT.TYPE.CHAT,
245286
},
@@ -254,6 +295,11 @@ describe('OptionsListUtils', () => {
254295
reportID: '14',
255296
participantAccountIDs: [1, 10, 3],
256297
visibleChatMemberAccountIDs: [1, 10, 3],
298+
participants: {
299+
1: {},
300+
10: {},
301+
3: {},
302+
},
257303
reportName: '',
258304
oldPolicyName: 'Avengers Room',
259305
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS,
@@ -271,6 +317,10 @@ describe('OptionsListUtils', () => {
271317
reportID: '15',
272318
participantAccountIDs: [3, 4],
273319
visibleChatMemberAccountIDs: [3, 4],
320+
participants: {
321+
3: {},
322+
4: {},
323+
},
274324
reportName: 'Spider-Man, Black Panther',
275325
type: CONST.REPORT.TYPE.CHAT,
276326
chatType: CONST.REPORT.CHAT_TYPE.DOMAIN_ALL,

0 commit comments

Comments
 (0)