Skip to content

Commit

Permalink
Allow system account chat to be listed in LHN, fix chat icons
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl committed Apr 27, 2024
1 parent 10fc359 commit 4f3ab3c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const chatTypes = {
POLICY_ROOM: 'policyRoom',
POLICY_EXPENSE_CHAT: 'policyExpenseChat',
SELF_DM: 'selfDM',
SYSTEM_DM: 'system',
} as const;

// Explicit type annotation is required
Expand Down
7 changes: 1 addition & 6 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ function getOptions(
allPersonalDetailsOptions = lodashOrderBy(allPersonalDetailsOptions, [(personalDetail) => personalDetail.text?.toLowerCase()], 'asc');
}

const optionsToExclude: Option[] = [{login: CONST.EMAIL.NOTIFICATIONS}];
const optionsToExclude: Option[] = [];

// If we're including selected options from the search results, we only want to exclude them if the search input is empty
// This is because on certain pages, we show the selected options at the top when the search input is empty
Expand Down Expand Up @@ -1753,11 +1753,6 @@ function getOptions(
break;
}

// Skip [email protected]
if (reportOption.login === CONST.EMAIL.NOTIFICATIONS) {
continue;
}

const isCurrentUserOwnedPolicyExpenseChatThatCouldShow =
reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption.isArchivedRoom;

Expand Down
15 changes: 13 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,10 @@ function isSelfDM(report: OnyxEntry<Report>): boolean {
return getChatType(report) === CONST.REPORT.CHAT_TYPE.SELF_DM;
}

function isSystemDM(report: OnyxEntry<Report>): boolean {
return getChatType(report) === CONST.REPORT.CHAT_TYPE.SYSTEM_DM;
}

function isGroupChat(report: OnyxEntry<Report> | Partial<Report>): boolean {
return getChatType(report) === CONST.REPORT.CHAT_TYPE.GROUP;
}
Expand Down Expand Up @@ -1944,6 +1948,10 @@ function getIcons(
return getIconsForParticipants([currentUserAccountID ?? 0], personalDetails);
}

if (isSystemDM(report)) {
return getIconsForParticipants([CONST.ACCOUNT_ID.NOTIFICATIONS ?? 0], personalDetails);
}

if (isGroupChat(report)) {
const groupChatIcon = {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand Down Expand Up @@ -3039,6 +3047,10 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true);
}

if (isSystemDM(report)) {
formattedName = getDisplayNameForParticipant(CONST.ACCOUNT_ID.NOTIFICATIONS);
}

if (formattedName) {
return formattedName;
}
Expand Down Expand Up @@ -4804,8 +4816,6 @@ function shouldReportBeInOptionList({
report?.reportName === undefined ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
report?.isHidden ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
report?.participantAccountIDs?.includes(CONST.ACCOUNT_ID.NOTIFICATIONS) ||
(report?.participantAccountIDs?.length === 0 &&
!isChatThread(report) &&
!isPublicRoom(report) &&
Expand Down Expand Up @@ -6408,6 +6418,7 @@ export {
isReportParticipant,
isSelfDM,
isSettled,
isSystemDM,
isTaskReport,
isThread,
isThreadFirstChat,
Expand Down

0 comments on commit 4f3ab3c

Please sign in to comment.