Skip to content

Commit 6da74e4

Browse files
committed
handling new system report type
1 parent 9a58f4f commit 6da74e4

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

src/CONST.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const chatTypes = {
5353
POLICY_ROOM: 'policyRoom',
5454
POLICY_EXPENSE_CHAT: 'policyExpenseChat',
5555
SELF_DM: 'selfDM',
56+
SYSTEM: 'system',
5657
} as const;
5758

5859
// Explicit type annotation is required
@@ -1202,7 +1203,6 @@ const CONST = {
12021203
CHRONOS: 'chronos@expensify.com',
12031204
CONCIERGE: 'concierge@expensify.com',
12041205
CONTRIBUTORS: 'contributors@expensify.com',
1205-
EXPENSIFY_PERSONA: 'expensify@expensify.com',
12061206
FIRST_RESPONDER: 'firstresponders@expensify.com',
12071207
GUIDES_DOMAIN: 'team.expensify.com',
12081208
HELP: 'help@expensify.com',

src/libs/ReportUtils.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,10 @@ function isGroupChat(report: OnyxEntry<Report> | Partial<Report>): boolean {
978978
return getChatType(report) === CONST.REPORT.CHAT_TYPE.GROUP;
979979
}
980980

981+
function isSystemChat(report: OnyxEntry<Report> | Partial<Report>): boolean {
982+
return getChatType(report) === CONST.REPORT.CHAT_TYPE.SYSTEM;
983+
}
984+
981985
/**
982986
* Only returns true if this is our main 1:1 DM report with Concierge
983987
*/
@@ -4791,7 +4795,6 @@ function shouldReportBeInOptionList({
47914795
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
47924796
report?.isHidden ||
47934797
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
4794-
report?.participantAccountIDs?.includes(CONST.ACCOUNT_ID.NOTIFICATIONS) ||
47954798
(report?.participantAccountIDs?.length === 0 &&
47964799
!isChatThread(report) &&
47974800
!isPublicRoom(report) &&
@@ -4800,7 +4803,8 @@ function shouldReportBeInOptionList({
48004803
!isMoneyRequestReport(report) &&
48014804
!isTaskReport(report) &&
48024805
!isSelfDM(report) &&
4803-
!isGroupChat(report))
4806+
!isGroupChat(report) &&
4807+
!isSystemChat(report))
48044808
) {
48054809
return false;
48064810
}
@@ -4877,6 +4881,18 @@ function shouldReportBeInOptionList({
48774881
return true;
48784882
}
48794883

4884+
/**
4885+
* Returns the system report from the list of reports.
4886+
* TODO: this method may not be necessary if the participants list of the system report is filled correctly
4887+
*/
4888+
function getSystemChat(): OnyxEntry<Report> {
4889+
if (!allReports) {
4890+
return null;
4891+
}
4892+
4893+
return Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) ?? null;
4894+
}
4895+
48804896
/**
48814897
* Attempts to find a report in onyx with the provided list of participants. Does not include threads, task, expense, room, and policy expense chat.
48824898
*/
@@ -6306,6 +6322,7 @@ export {
63066322
getRoomWelcomeMessage,
63076323
getRootParentReport,
63086324
getRouteFromLink,
6325+
getSystemChat,
63096326
getTaskAssigneeChatOnyxData,
63106327
getTransactionDetails,
63116328
getTransactionReportName,

src/libs/SidebarUtils.ts

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import * as OptionsListUtils from './OptionsListUtils';
2020
import * as ReportActionsUtils from './ReportActionsUtils';
2121
import * as ReportUtils from './ReportUtils';
2222
import * as TaskUtils from './TaskUtils';
23+
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
2324

2425
const visibleReportActionItems: ReportActions = {};
2526
Onyx.connect({
@@ -245,6 +246,11 @@ function getOptionData({
245246
participantAccountIDs = [report.ownerAccountID ?? 0];
246247
}
247248

249+
// TODO: this is added for the testing purposes only - should be removed once participants list of the system report is filled
250+
if (report.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) {
251+
participantAccountIDs = [report.ownerAccountID ?? 0, ...PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.NOTIFICATIONS])];
252+
}
253+
248254
const participantPersonalDetailList = Object.values(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)) as PersonalDetails[];
249255
const personalDetail = participantPersonalDetailList[0] ?? {};
250256
const hasErrors = Object.keys(result.allReportErrors ?? {}).length !== 0;

src/libs/actions/Report.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -3029,14 +3029,12 @@ function completeOnboarding(
30293029
},
30303030
adminsChatReportID?: string,
30313031
) {
3032-
let targetEmail: string = CONST.EMAIL.CONCIERGE;
3033-
if (currentUserAccountID % 2 === 1) {
3034-
// for odd accountID, we will use the expensify persona instead of concierge
3035-
targetEmail = CONST.EMAIL.EXPENSIFY_PERSONA;
3036-
}
3032+
const isAccountIDOdd = currentUserAccountID % 2 === 1;
3033+
const targetEmail = isAccountIDOdd ? CONST.EMAIL.NOTIFICATIONS : CONST.EMAIL.CONCIERGE;
30373034

30383035
const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0];
3039-
const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID]);
3036+
// TODO: using getSystemChat is rather not necessary if we could have participants list filled correctly
3037+
const targetChatReport= isAccountIDOdd ? ReportUtils.getSystemChat() : ReportUtils.getChatByParticipants([actorAccountID]);
30403038
const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {};
30413039

30423040
// Mention message

0 commit comments

Comments
 (0)