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

Allow system account chat to be listed in LHN, fix chat icons #41127

Closed
wants to merge 2 commits into from
Closed
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
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
8 changes: 7 additions & 1 deletion src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
const isChatRoom = ReportUtils.isChatRoom(report);
const isSelfDM = ReportUtils.isSelfDM(report);
const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM);
const isSystemDM = ReportUtils.isSystemDM(report);
const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isSystemDM);
const participantAccountIDs = report?.participantAccountIDs ?? [];
const isMultipleParticipant = participantAccountIDs.length > 1;
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);
Expand Down Expand Up @@ -133,6 +134,11 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
<Text>{translate('reportActionsView.beginningOfChatHistorySelfDM')}</Text>
</Text>
)}
{isSystemDM && (
<Text>
<Text>{translate('reportActionsView.beginningOfChatHistorySystemDM')}</Text>
</Text>
)}
{isDefault && (
<Text>
<Text>{translate('reportActionsView.beginningOfChatHistory')}</Text>
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ export default {
beginningOfChatHistoryPolicyExpenseChatPartTwo: ' and ',
beginningOfChatHistoryPolicyExpenseChatPartThree: ' starts here! 🎉 This is the place to chat, submit expenses and settle up.',
beginningOfChatHistorySelfDM: 'This is your personal space. Use it for notes, tasks, drafts, and reminders.',
beginningOfChatHistorySystemDM: "Welcome! Let's get you set up.",
chatWithAccountManager: 'Chat with your account manager here',
sayHello: 'Say hello!',
yourSpace: 'Your space',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ export default {
beginningOfChatHistoryPolicyExpenseChatPartTwo: ' y ',
beginningOfChatHistoryPolicyExpenseChatPartThree: ' empieza aquí! 🎉 Este es el lugar donde chatear y presentar o pagar gastos.',
beginningOfChatHistorySelfDM: 'Este es tu espacio personal. Úsalo para notas, tareas, borradores y recordatorios.',
beginningOfChatHistorySystemDM: "Welcome! Let's get you set up.",
chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí',
sayHello: '¡Saluda!',
yourSpace: 'Tu espacio',
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
17 changes: 14 additions & 3 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 @@ -5192,7 +5202,7 @@ function isGroupChatAdmin(report: OnyxEntry<Report>, accountID: number) {
*/
function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, reportParticipants: number[], canUseTrackExpense = true, filterDeprecatedTypes = false): IOUType[] {
// In any thread or task report, we do not allow any new expenses yet
if (isChatThread(report) || isTaskReport(report) || (!canUseTrackExpense && isSelfDM(report))) {
if (isChatThread(report) || isTaskReport(report) || (!canUseTrackExpense && isSelfDM(report)) || isSystemDM(report)) {
return [];
}

Expand Down Expand Up @@ -6408,6 +6418,7 @@ export {
isReportParticipant,
isSelfDM,
isSettled,
isSystemDM,
isTaskReport,
isThread,
isThreadFirstChat,
Expand Down
Loading