From e343aa68acc529461e7612572b753169ee736c0e Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 22 Apr 2024 11:24:12 +0200 Subject: [PATCH 01/19] new persona added --- src/CONST.ts | 1 + src/libs/actions/Report.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index 2e14aa7cf21f..0725fb47a85b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1202,6 +1202,7 @@ const CONST = { CHRONOS: 'chronos@expensify.com', CONCIERGE: 'concierge@expensify.com', CONTRIBUTORS: 'contributors@expensify.com', + EXPENSIFY_PERSONA: 'expensify@expensify.com', FIRST_RESPONDER: 'firstresponders@expensify.com', GUIDES_DOMAIN: 'team.expensify.com', HELP: 'help@expensify.com', diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 7542ca12c592..8260b6194b21 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3029,7 +3029,7 @@ function completeOnboarding( }, adminsChatReportID?: string, ) { - const targetEmail = CONST.EMAIL.CONCIERGE; + const targetEmail = CONST.EMAIL.EXPENSIFY_PERSONA; const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; From 9a58f4fc89739c5a05df7bf8e56d0b1b51904b5d Mon Sep 17 00:00:00 2001 From: burczu Date: Mon, 22 Apr 2024 12:49:50 +0200 Subject: [PATCH 02/19] using expensify persona only for odd account ids --- src/libs/actions/Report.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 8260b6194b21..4afdeb5201a4 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3029,7 +3029,12 @@ function completeOnboarding( }, adminsChatReportID?: string, ) { - const targetEmail = CONST.EMAIL.EXPENSIFY_PERSONA; + let targetEmail: string = CONST.EMAIL.CONCIERGE; + if (currentUserAccountID % 2 === 1) { + // for odd accountID, we will use the expensify persona instead of concierge + targetEmail = CONST.EMAIL.EXPENSIFY_PERSONA; + } + const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; From 6da74e4ca18a8963ada6cf7083d7cbb84871ca32 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 26 Apr 2024 10:56:25 +0200 Subject: [PATCH 03/19] handling new system report type --- src/CONST.ts | 2 +- src/libs/ReportUtils.ts | 21 +++++++++++++++++++-- src/libs/SidebarUtils.ts | 6 ++++++ src/libs/actions/Report.ts | 10 ++++------ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 0725fb47a85b..1aaea219d3bd 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -53,6 +53,7 @@ const chatTypes = { POLICY_ROOM: 'policyRoom', POLICY_EXPENSE_CHAT: 'policyExpenseChat', SELF_DM: 'selfDM', + SYSTEM: 'system', } as const; // Explicit type annotation is required @@ -1202,7 +1203,6 @@ const CONST = { CHRONOS: 'chronos@expensify.com', CONCIERGE: 'concierge@expensify.com', CONTRIBUTORS: 'contributors@expensify.com', - EXPENSIFY_PERSONA: 'expensify@expensify.com', FIRST_RESPONDER: 'firstresponders@expensify.com', GUIDES_DOMAIN: 'team.expensify.com', HELP: 'help@expensify.com', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 121518130cb4..1aac5cd716c5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -978,6 +978,10 @@ function isGroupChat(report: OnyxEntry | Partial): boolean { return getChatType(report) === CONST.REPORT.CHAT_TYPE.GROUP; } +function isSystemChat(report: OnyxEntry | Partial): boolean { + return getChatType(report) === CONST.REPORT.CHAT_TYPE.SYSTEM; +} + /** * Only returns true if this is our main 1:1 DM report with Concierge */ @@ -4791,7 +4795,6 @@ function shouldReportBeInOptionList({ // 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) && @@ -4800,7 +4803,8 @@ function shouldReportBeInOptionList({ !isMoneyRequestReport(report) && !isTaskReport(report) && !isSelfDM(report) && - !isGroupChat(report)) + !isGroupChat(report) && + !isSystemChat(report)) ) { return false; } @@ -4877,6 +4881,18 @@ function shouldReportBeInOptionList({ return true; } +/** + * Returns the system report from the list of reports. + * TODO: this method may not be necessary if the participants list of the system report is filled correctly + */ +function getSystemChat(): OnyxEntry { + if (!allReports) { + return null; + } + + return Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) ?? null; +} + /** * Attempts to find a report in onyx with the provided list of participants. Does not include threads, task, expense, room, and policy expense chat. */ @@ -6306,6 +6322,7 @@ export { getRoomWelcomeMessage, getRootParentReport, getRouteFromLink, + getSystemChat, getTaskAssigneeChatOnyxData, getTransactionDetails, getTransactionReportName, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index d230f58e46f9..2c52af317be5 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -20,6 +20,7 @@ import * as OptionsListUtils from './OptionsListUtils'; import * as ReportActionsUtils from './ReportActionsUtils'; import * as ReportUtils from './ReportUtils'; import * as TaskUtils from './TaskUtils'; +import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; const visibleReportActionItems: ReportActions = {}; Onyx.connect({ @@ -245,6 +246,11 @@ function getOptionData({ participantAccountIDs = [report.ownerAccountID ?? 0]; } + // TODO: this is added for the testing purposes only - should be removed once participants list of the system report is filled + if (report.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) { + participantAccountIDs = [report.ownerAccountID ?? 0, ...PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.NOTIFICATIONS])]; + } + const participantPersonalDetailList = Object.values(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)) as PersonalDetails[]; const personalDetail = participantPersonalDetailList[0] ?? {}; const hasErrors = Object.keys(result.allReportErrors ?? {}).length !== 0; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 4afdeb5201a4..4d5e99966323 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3029,14 +3029,12 @@ function completeOnboarding( }, adminsChatReportID?: string, ) { - let targetEmail: string = CONST.EMAIL.CONCIERGE; - if (currentUserAccountID % 2 === 1) { - // for odd accountID, we will use the expensify persona instead of concierge - targetEmail = CONST.EMAIL.EXPENSIFY_PERSONA; - } + const isAccountIDOdd = currentUserAccountID % 2 === 1; + const targetEmail = isAccountIDOdd ? CONST.EMAIL.NOTIFICATIONS : CONST.EMAIL.CONCIERGE; const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; - const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID]); + // TODO: using getSystemChat is rather not necessary if we could have participants list filled correctly + const targetChatReport= isAccountIDOdd ? ReportUtils.getSystemChat() : ReportUtils.getChatByParticipants([actorAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; // Mention message From aaa3cd4c9bf2b136b430a61f9655308df57e88cc Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 26 Apr 2024 11:35:07 +0200 Subject: [PATCH 04/19] navigating to system chat at the end of the onboarding process added --- src/libs/AccountUtils.ts | 4 +++- src/libs/SidebarUtils.ts | 2 +- src/libs/actions/Report.ts | 18 ++++++++++++++++-- .../BaseOnboardingPersonalDetails.tsx | 7 ++++++- .../OnboardingWork/BaseOnboardingWork.tsx | 7 ++++++- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/libs/AccountUtils.ts b/src/libs/AccountUtils.ts index d903584e15b4..8bc7037e9682 100644 --- a/src/libs/AccountUtils.ts +++ b/src/libs/AccountUtils.ts @@ -5,4 +5,6 @@ import type {Account} from '@src/types/onyx'; const isValidateCodeFormSubmitting = (account: OnyxEntry) => !!account?.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); -export default {isValidateCodeFormSubmitting}; +const isAccountIDOddNumber = (accountID: number) => accountID % 2 === 1; + +export default {isValidateCodeFormSubmitting, isAccountIDOddNumber}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 2c52af317be5..50d9cea26efe 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -17,10 +17,10 @@ import localeCompare from './LocaleCompare'; import * as LocalePhoneNumber from './LocalePhoneNumber'; import * as Localize from './Localize'; import * as OptionsListUtils from './OptionsListUtils'; +import * as PersonalDetailsUtils from './PersonalDetailsUtils'; import * as ReportActionsUtils from './ReportActionsUtils'; import * as ReportUtils from './ReportUtils'; import * as TaskUtils from './TaskUtils'; -import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; const visibleReportActionItems: ReportActions = {}; Onyx.connect({ diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 4d5e99966323..714cf2182db9 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -8,6 +8,7 @@ import Onyx from 'react-native-onyx'; import type {PartialDeep, ValueOf} from 'type-fest'; import type {Emoji} from '@assets/emojis/types'; import type {FileObject} from '@components/AttachmentModal'; +import AccountUtils from '@libs/AccountUtils'; import * as ActiveClientManager from '@libs/ActiveClientManager'; import * as API from '@libs/API'; import type { @@ -1930,6 +1931,18 @@ function navigateToConciergeChat(shouldDismissModal = false, checkIfCurrentPageA } } +/** + * Navigates to the 1:1 system chat + */ +function navigateToSystemChat() { + // TODO: when system report participants list is filled, we could just use `ReportUtils.getChatByParticipants()` method insted `getSystemChat()` + const systemChatReport = ReportUtils.getSystemChat(); + + if (systemChatReport && systemChatReport.reportID) { + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(systemChatReport.reportID)); + } +} + /** Add a policy report (workspace room) optimistically and navigate to it. */ function addPolicyReport(policyReport: ReportUtils.OptimisticChatReport) { const createdReportAction = ReportUtils.buildOptimisticCreatedReportAction(CONST.POLICY.OWNER_EMAIL_FAKE); @@ -3029,12 +3042,12 @@ function completeOnboarding( }, adminsChatReportID?: string, ) { - const isAccountIDOdd = currentUserAccountID % 2 === 1; + const isAccountIDOdd = AccountUtils.isAccountIDOddNumber(currentUserAccountID ?? 0); const targetEmail = isAccountIDOdd ? CONST.EMAIL.NOTIFICATIONS : CONST.EMAIL.CONCIERGE; const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; // TODO: using getSystemChat is rather not necessary if we could have participants list filled correctly - const targetChatReport= isAccountIDOdd ? ReportUtils.getSystemChat() : ReportUtils.getChatByParticipants([actorAccountID]); + const targetChatReport = isAccountIDOdd ? ReportUtils.getSystemChat() : ReportUtils.getChatByParticipants([actorAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; // Mention message @@ -3736,6 +3749,7 @@ export { saveReportActionDraftNumberOfLines, deleteReportComment, navigateToConciergeChat, + navigateToSystemChat, addPolicyReport, deleteReport, navigateToConciergeChatAndDeleteReport, diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index 7049b04cc293..0082ede92c4f 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -7,6 +7,7 @@ import type {FormOnyxValues} from '@components/Form/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import KeyboardAvoidingView from '@components/KeyboardAvoidingView'; import OfflineIndicator from '@components/OfflineIndicator'; +import {useSession} from '@components/OnyxProvider'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; @@ -16,6 +17,7 @@ import useLocalize from '@hooks/useLocalize'; import useOnboardingLayout from '@hooks/useOnboardingLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import AccountUtils from '@libs/AccountUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as ValidationUtils from '@libs/ValidationUtils'; @@ -37,6 +39,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat const {shouldUseNarrowLayout} = useOnboardingLayout(); const {inputCallbackRef} = useAutoFocusInput(); const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false); + const {accountID} = useSession(); useDisableModalDismissOnEscape(); @@ -69,6 +72,8 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat // Otherwise stay on the chats screen. if (isSmallScreenWidth) { Navigation.navigate(ROUTES.HOME); + } else if (AccountUtils.isAccountIDOddNumber(accountID ?? 0)) { + Report.navigateToSystemChat(); } else { Report.navigateToConciergeChat(); } @@ -79,7 +84,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat Navigation.navigate(ROUTES.WELCOME_VIDEO_ROOT); }, variables.welcomeVideoDelay); }, - [currentUserPersonalDetails.login, isSmallScreenWidth, onboardingPurposeSelected], + [currentUserPersonalDetails.login, isSmallScreenWidth, onboardingPurposeSelected, accountID], ); const validate = (values: FormOnyxValues<'onboardingPersonalDetailsForm'>) => { diff --git a/src/pages/OnboardingWork/BaseOnboardingWork.tsx b/src/pages/OnboardingWork/BaseOnboardingWork.tsx index 151c1bb35ea2..d2e583d778c2 100644 --- a/src/pages/OnboardingWork/BaseOnboardingWork.tsx +++ b/src/pages/OnboardingWork/BaseOnboardingWork.tsx @@ -7,6 +7,7 @@ import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import KeyboardAvoidingView from '@components/KeyboardAvoidingView'; import OfflineIndicator from '@components/OfflineIndicator'; +import {useSession} from '@components/OnyxProvider'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; @@ -15,6 +16,7 @@ import useLocalize from '@hooks/useLocalize'; import useOnboardingLayout from '@hooks/useOnboardingLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import AccountUtils from '@libs/AccountUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as ValidationUtils from '@libs/ValidationUtils'; @@ -32,6 +34,7 @@ function BaseOnboardingWork({currentUserPersonalDetails, shouldUseNativeStyles, const {translate} = useLocalize(); const {isSmallScreenWidth} = useWindowDimensions(); const {shouldUseNarrowLayout} = useOnboardingLayout(); + const {accountID} = useSession(); useDisableModalDismissOnEscape(); @@ -62,6 +65,8 @@ function BaseOnboardingWork({currentUserPersonalDetails, shouldUseNativeStyles, // Otherwise stay on the chats screen. if (isSmallScreenWidth) { Navigation.navigate(ROUTES.HOME); + } else if (AccountUtils.isAccountIDOddNumber(accountID ?? 0)) { + Report.navigateToSystemChat(); } else { Report.navigateToConciergeChat(); } @@ -72,7 +77,7 @@ function BaseOnboardingWork({currentUserPersonalDetails, shouldUseNativeStyles, Navigation.navigate(ROUTES.WELCOME_VIDEO_ROOT); }, variables.welcomeVideoDelay); }, - [currentUserPersonalDetails.firstName, currentUserPersonalDetails.lastName, currentUserPersonalDetails.login, isSmallScreenWidth, onboardingPurposeSelected], + [currentUserPersonalDetails.firstName, currentUserPersonalDetails.lastName, currentUserPersonalDetails.login, isSmallScreenWidth, onboardingPurposeSelected, accountID], ); const validate = (values: FormOnyxValues<'onboardingWorkForm'>) => { From 282490a17937d7928230d573dc2af8834e5fcd80 Mon Sep 17 00:00:00 2001 From: burczu Date: Fri, 26 Apr 2024 11:41:47 +0200 Subject: [PATCH 05/19] addional todo comment added --- src/libs/ReportUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 1aac5cd716c5..e58dd3e54b12 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4804,6 +4804,7 @@ function shouldReportBeInOptionList({ !isTaskReport(report) && !isSelfDM(report) && !isGroupChat(report) && + // TODO: this shouldn't be necessary if the system report has participants list filled !isSystemChat(report)) ) { return false; From 0410d8ff2bb5ac120aeb3bf9fe5d98a5b579132f Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 30 Apr 2024 16:01:49 +0200 Subject: [PATCH 06/19] fix: minor fix --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c9213d5460ea..cbce4a48928d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4983,7 +4983,7 @@ function shouldReportBeInOptionList({ !isTaskReport(report) && !isSelfDM(report) && !isGroupChat(report) && - !isInvoiceRoom(report)) && + !isInvoiceRoom(report) && // TODO: this shouldn't be necessary if the system report has participants list filled !isSystemChat(report)) ) { From 179575fb7ff9e91b9f7a87f90162d03191875c09 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 30 Apr 2024 17:03:58 +0200 Subject: [PATCH 07/19] fix: remove comment --- src/libs/ReportUtils.ts | 1 - src/libs/actions/Report.ts | 24 +++++++++++++++---- .../BaseOnboardingPersonalDetails.tsx | 2 ++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index cbce4a48928d..967004c7184d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5064,7 +5064,6 @@ function shouldReportBeInOptionList({ /** * Returns the system report from the list of reports. - * TODO: this method may not be necessary if the participants list of the system report is filled correctly */ function getSystemChat(): OnyxEntry { if (!allReports) { diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 9fe8f8d9fffa..4ef0b9e22d02 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -871,7 +871,11 @@ function openReport( if (isFromDeepLink) { // eslint-disable-next-line rulesdir/no-api-side-effects-method - API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_REPORT, parameters, {optimisticData, successData, failureData}).finally(() => { + API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_REPORT, parameters, { + optimisticData, + successData, + failureData, + }).finally(() => { Onyx.set(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, false); }); } else { @@ -1851,7 +1855,10 @@ function updateDescription(reportID: string, previousValue: string, newValue: st { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: {description: parsedDescription, pendingFields: {description: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}}, + value: { + description: parsedDescription, + pendingFields: {description: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + }, }, ]; const failureData: OnyxUpdate[] = [ @@ -1930,7 +1937,6 @@ function navigateToConciergeChat(shouldDismissModal = false, checkIfCurrentPageA * Navigates to the 1:1 system chat */ function navigateToSystemChat() { - // TODO: when system report participants list is filled, we could just use `ReportUtils.getChatByParticipants()` method insted `getSystemChat()` const systemChatReport = ReportUtils.getSystemChat(); if (systemChatReport && systemChatReport.reportID) { @@ -2215,7 +2221,10 @@ function shouldShowReportActionNotification(reportID: string, action: ReportActi // If this notification was delayed and the user saw the message already, don't show it if (action && report?.lastReadTime && report.lastReadTime >= action.created) { - Log.info(`${tag} No notification because the comment was already read`, false, {created: action.created, lastReadTime: report.lastReadTime}); + Log.info(`${tag} No notification because the comment was already read`, false, { + created: action.created, + lastReadTime: report.lastReadTime, + }); return false; } @@ -2243,7 +2252,10 @@ function showReportActionNotification(reportID: string, reportAction: ReportActi const report = allReports?.[reportID] ?? null; if (!report) { - Log.hmmm("[LocalNotification] couldn't show report action notification because the report wasn't found", {reportID, reportActionID: reportAction.reportActionID}); + Log.hmmm("[LocalNotification] couldn't show report action notification because the report wasn't found", { + reportID, + reportActionID: reportAction.reportActionID, + }); return; } @@ -3027,6 +3039,8 @@ function completeOnboarding( const isAccountIDOdd = AccountUtils.isAccountIDOddNumber(currentUserAccountID ?? 0); const targetEmail = isAccountIDOdd ? CONST.EMAIL.NOTIFICATIONS : CONST.EMAIL.CONCIERGE; + console.log({currentUserAccountID}); + const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; // TODO: using getSystemChat is rather not necessary if we could have participants list filled correctly const targetChatReport = isAccountIDOdd ? ReportUtils.getSystemChat() : ReportUtils.getChatByParticipants([actorAccountID]); diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index 036408226e71..eb4d4e50ffbd 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -42,6 +42,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat const {accountID} = useSession(); useDisableModalDismissOnEscape(); + console.log({accountID}); const completeEngagement = useCallback( (values: FormOnyxValues<'onboardingPersonalDetailsForm'>) => { @@ -67,6 +68,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat }); Navigation.dismissModal(); + console.log({accountID}); // Only navigate to concierge chat when central pane is visible // Otherwise stay on the chats screen. From 9cba84a26366e0eb611ead798c877a0419b5eb4a Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 30 Apr 2024 17:12:31 +0200 Subject: [PATCH 08/19] fix: remove unnecessary condition --- src/libs/ReportUtils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 967004c7184d..ed9639ab765a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4983,9 +4983,7 @@ function shouldReportBeInOptionList({ !isTaskReport(report) && !isSelfDM(report) && !isGroupChat(report) && - !isInvoiceRoom(report) && - // TODO: this shouldn't be necessary if the system report has participants list filled - !isSystemChat(report)) + !isInvoiceRoom(report)) ) { return false; } From ba3aa46bd40fbb1be8be752448c2ff254860e463 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 30 Apr 2024 17:25:53 +0200 Subject: [PATCH 09/19] fix: remove console log --- src/libs/actions/Report.ts | 12 ++++++++---- .../BaseOnboardingPersonalDetails.tsx | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 4ef0b9e22d02..7d7e93463af2 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -351,7 +351,10 @@ function subscribeToReportTypingEvents(reportID: string) { delete typingWatchTimers[reportUserIdentifier]; }, 1500); }).catch((error) => { - Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', {errorType: error.type, pusherChannelName}); + Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', { + errorType: error.type, + pusherChannelName, + }); }); } @@ -382,7 +385,10 @@ function subscribeToReportLeavingEvents(reportID: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM}${reportID}`, true); }).catch((error) => { - Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', {errorType: error.type, pusherChannelName}); + Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', { + errorType: error.type, + pusherChannelName, + }); }); } @@ -3039,8 +3045,6 @@ function completeOnboarding( const isAccountIDOdd = AccountUtils.isAccountIDOddNumber(currentUserAccountID ?? 0); const targetEmail = isAccountIDOdd ? CONST.EMAIL.NOTIFICATIONS : CONST.EMAIL.CONCIERGE; - console.log({currentUserAccountID}); - const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; // TODO: using getSystemChat is rather not necessary if we could have participants list filled correctly const targetChatReport = isAccountIDOdd ? ReportUtils.getSystemChat() : ReportUtils.getChatByParticipants([actorAccountID]); diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index eb4d4e50ffbd..036408226e71 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -42,7 +42,6 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat const {accountID} = useSession(); useDisableModalDismissOnEscape(); - console.log({accountID}); const completeEngagement = useCallback( (values: FormOnyxValues<'onboardingPersonalDetailsForm'>) => { @@ -68,7 +67,6 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat }); Navigation.dismissModal(); - console.log({accountID}); // Only navigate to concierge chat when central pane is visible // Otherwise stay on the chats screen. From 5c2e6d2b3f1319d52e79f0726dcc7e671a1f4e8f Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 2 May 2024 11:36:37 +0200 Subject: [PATCH 10/19] fix: remove unnecessary change --- src/libs/actions/Report.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 7d7e93463af2..270c126fbcad 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -351,10 +351,7 @@ function subscribeToReportTypingEvents(reportID: string) { delete typingWatchTimers[reportUserIdentifier]; }, 1500); }).catch((error) => { - Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', { - errorType: error.type, - pusherChannelName, - }); + Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', {errorType: error.type, pusherChannelName}); }); } @@ -385,10 +382,7 @@ function subscribeToReportLeavingEvents(reportID: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM}${reportID}`, true); }).catch((error) => { - Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', { - errorType: error.type, - pusherChannelName, - }); + Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', {errorType: error.type, pusherChannelName}); }); } From 36842b8d038974c945751ce7ad51fc026fed7c81 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 2 May 2024 11:42:50 +0200 Subject: [PATCH 11/19] fix: apply requested changes --- src/libs/ReportUtils.ts | 1 - src/libs/SidebarUtils.ts | 5 ----- src/libs/actions/Report.ts | 24 +++++------------------- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ed9639ab765a..1f3ececf17bd 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4973,7 +4973,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?.length === 0 && !isChatThread(report) && !isPublicRoom(report) && diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 3d0b214d8377..2360366dde73 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -245,11 +245,6 @@ function getOptionData({ participantAccountIDs = [report.ownerAccountID ?? 0]; } - // TODO: this is added for the testing purposes only - should be removed once participants list of the system report is filled - if (report.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) { - participantAccountIDs = [report.ownerAccountID ?? 0, ...PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.NOTIFICATIONS])]; - } - const participantPersonalDetailList = Object.values(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)) as PersonalDetails[]; const personalDetail = participantPersonalDetailList[0] ?? {}; const hasErrors = Object.keys(result.allReportErrors ?? {}).length !== 0; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 270c126fbcad..bb3855dd893a 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -871,11 +871,7 @@ function openReport( if (isFromDeepLink) { // eslint-disable-next-line rulesdir/no-api-side-effects-method - API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_REPORT, parameters, { - optimisticData, - successData, - failureData, - }).finally(() => { + API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_REPORT, parameters, {optimisticData, successData, failureData}).finally(() => { Onyx.set(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, false); }); } else { @@ -1855,10 +1851,7 @@ function updateDescription(reportID: string, previousValue: string, newValue: st { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: { - description: parsedDescription, - pendingFields: {description: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, - }, + value: {description: parsedDescription, pendingFields: {description: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}}, }, ]; const failureData: OnyxUpdate[] = [ @@ -2221,10 +2214,7 @@ function shouldShowReportActionNotification(reportID: string, action: ReportActi // If this notification was delayed and the user saw the message already, don't show it if (action && report?.lastReadTime && report.lastReadTime >= action.created) { - Log.info(`${tag} No notification because the comment was already read`, false, { - created: action.created, - lastReadTime: report.lastReadTime, - }); + Log.info(`${tag} No notification because the comment was already read`, false, {created: action.created, lastReadTime: report.lastReadTime}); return false; } @@ -2252,10 +2242,7 @@ function showReportActionNotification(reportID: string, reportAction: ReportActi const report = allReports?.[reportID] ?? null; if (!report) { - Log.hmmm("[LocalNotification] couldn't show report action notification because the report wasn't found", { - reportID, - reportActionID: reportAction.reportActionID, - }); + Log.hmmm("[LocalNotification] couldn't show report action notification because the report wasn't found", {reportID, reportActionID: reportAction.reportActionID}); return; } @@ -3040,8 +3027,7 @@ function completeOnboarding( const targetEmail = isAccountIDOdd ? CONST.EMAIL.NOTIFICATIONS : CONST.EMAIL.CONCIERGE; const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; - // TODO: using getSystemChat is rather not necessary if we could have participants list filled correctly - const targetChatReport = isAccountIDOdd ? ReportUtils.getSystemChat() : ReportUtils.getChatByParticipants([actorAccountID]); + const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; // Mention message From a6b6593adaf35c4ea1ec5c8282845fc5e3845c17 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 2 May 2024 13:56:59 +0200 Subject: [PATCH 12/19] fix: lint --- src/libs/SidebarUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 2360366dde73..c0d0c9020a64 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -18,7 +18,6 @@ import localeCompare from './LocaleCompare'; import * as LocalePhoneNumber from './LocalePhoneNumber'; import * as Localize from './Localize'; import * as OptionsListUtils from './OptionsListUtils'; -import * as PersonalDetailsUtils from './PersonalDetailsUtils'; import * as ReportActionsUtils from './ReportActionsUtils'; import * as ReportUtils from './ReportUtils'; import * as TaskUtils from './TaskUtils'; From 8365690feaa4fba5fda352ec3a69f80ac5f00645 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 4 Jun 2024 18:24:35 +0200 Subject: [PATCH 13/19] fix: apply requested changes --- src/libs/API/parameters/CompleteGuidedSetupParams.ts | 1 + src/libs/actions/Report.ts | 1 + src/pages/OnboardingWork/BaseOnboardingWork.tsx | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/API/parameters/CompleteGuidedSetupParams.ts b/src/libs/API/parameters/CompleteGuidedSetupParams.ts index e3a0309d5113..8e1273ac6053 100644 --- a/src/libs/API/parameters/CompleteGuidedSetupParams.ts +++ b/src/libs/API/parameters/CompleteGuidedSetupParams.ts @@ -3,6 +3,7 @@ import type {OnboardingPurposeType} from '@src/CONST'; type CompleteGuidedSetupParams = { firstName: string; lastName: string; + actorAccountID: number; guidedSetupData: string; engagementChoice: OnboardingPurposeType; }; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 8bbe027f73c0..01216e91d3fc 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3428,6 +3428,7 @@ function completeOnboarding( engagementChoice, firstName, lastName, + actorAccountID, guidedSetupData: JSON.stringify(guidedSetupData), }; diff --git a/src/pages/OnboardingWork/BaseOnboardingWork.tsx b/src/pages/OnboardingWork/BaseOnboardingWork.tsx index 3f89d10942f7..95dde3107a15 100644 --- a/src/pages/OnboardingWork/BaseOnboardingWork.tsx +++ b/src/pages/OnboardingWork/BaseOnboardingWork.tsx @@ -15,7 +15,6 @@ import useLocalize from '@hooks/useLocalize'; import useOnboardingLayout from '@hooks/useOnboardingLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import AccountUtils from '@libs/AccountUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as ValidationUtils from '@libs/ValidationUtils'; @@ -34,7 +33,6 @@ function BaseOnboardingWork({shouldUseNativeStyles, onboardingPurposeSelected, o const {translate} = useLocalize(); const {isSmallScreenWidth} = useWindowDimensions(); const {shouldUseNarrowLayout} = useOnboardingLayout(); - const {accountID} = useSession(); useDisableModalDismissOnEscape(); From 717fe74ca2a9260856ede78d4e509d06962deb52 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 4 Jun 2024 19:00:34 +0200 Subject: [PATCH 14/19] fix: lint --- src/pages/OnboardingWork/BaseOnboardingWork.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/OnboardingWork/BaseOnboardingWork.tsx b/src/pages/OnboardingWork/BaseOnboardingWork.tsx index 95dde3107a15..b0e01d0c8caa 100644 --- a/src/pages/OnboardingWork/BaseOnboardingWork.tsx +++ b/src/pages/OnboardingWork/BaseOnboardingWork.tsx @@ -7,7 +7,6 @@ import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import KeyboardAvoidingView from '@components/KeyboardAvoidingView'; import OfflineIndicator from '@components/OfflineIndicator'; -import {useSession} from '@components/OnyxProvider'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import useDisableModalDismissOnEscape from '@hooks/useDisableModalDismissOnEscape'; From e921c9216a935cdc5abe669df1f1aae893ed25de Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Mon, 10 Jun 2024 10:24:06 +0200 Subject: [PATCH 15/19] fix: show Persona chat in LHN --- src/libs/ReportUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b63087763d32..ba9559a5b435 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5275,7 +5275,6 @@ function shouldReportBeInOptionList({ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing report?.isHidden || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - participantAccountIDs.includes(CONST.ACCOUNT_ID.NOTIFICATIONS) || (participantAccountIDs.length === 0 && !isChatThread(report) && !isPublicRoom(report) && From eab9f0b0870a41e077e012dd0087eb10fdb5a0f5 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Mon, 10 Jun 2024 10:24:40 +0200 Subject: [PATCH 16/19] fix: remove unnecessary comment --- src/libs/ReportUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ba9559a5b435..eb4dfaf3d558 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5274,7 +5274,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 (participantAccountIDs.length === 0 && !isChatThread(report) && !isPublicRoom(report) && From 99b739832f7093e29e93fd5c90b48ab1eeb0a3cf Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Mon, 10 Jun 2024 10:29:36 +0200 Subject: [PATCH 17/19] fix: show only Expensify name for persona chat --- src/components/LHNOptionsList/OptionRowLHN.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 851e2a9fdd16..1aa3fe47212d 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -221,7 +221,8 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti !!optionItem.isThread || !!optionItem.isMoneyRequestReport || !!optionItem.isInvoiceReport || - ReportUtils.isGroupChat(report) + ReportUtils.isGroupChat(report) || + ReportUtils.isSystemChat(report) } /> {isStatusVisible && ( From 08a87cdd2185761c39cb2277363827eb600c544a Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 11 Jun 2024 09:43:57 +0200 Subject: [PATCH 18/19] fix: show persona chat only for onboarded by persona users --- src/libs/ReportUtils.ts | 14 ++------------ src/libs/SidebarUtils.ts | 7 +++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6cade245b067..4de976aaf160 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5347,6 +5347,8 @@ 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 + participantAccountIDs.includes(CONST.ACCOUNT_ID.NOTIFICATIONS) || (participantAccountIDs.length === 0 && !isChatThread(report) && !isPublicRoom(report) && @@ -5435,17 +5437,6 @@ function shouldReportBeInOptionList({ return true; } -/** - * Returns the system report from the list of reports. - */ -function getSystemChat(): OnyxEntry { - if (!allReports) { - return null; - } - - return Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) ?? null; -} - /** * Attempts to find a report in onyx with the provided list of participants. Does not include threads, task, expense, room, and policy expense chat. */ @@ -7067,7 +7058,6 @@ export { getRoomWelcomeMessage, getRootParentReport, getRouteFromLink, - getSystemChat, getTaskAssigneeChatOnyxData, getTransactionDetails, getTransactionReportName, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 3df823db22df..119bbc3ba12a 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -12,6 +12,7 @@ import type PriorityMode from '@src/types/onyx/PriorityMode'; import type Report from '@src/types/onyx/Report'; import type ReportAction from '@src/types/onyx/ReportAction'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; +import AccountUtils from './AccountUtils'; import * as CollectionUtils from './CollectionUtils'; import {hasValidDraftComment} from './DraftCommentUtils'; import localeCompare from './LocaleCompare'; @@ -104,6 +105,12 @@ function getOrderedReportIDs( return false; } + const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number); + + if (currentUserAccountID && AccountUtils.isAccountIDOddNumber(currentUserAccountID) && participantAccountIDs.includes(CONST.ACCOUNT_ID.NOTIFICATIONS)) { + return true; + } + return ReportUtils.shouldReportBeInOptionList({ report, currentReportId: currentReportId ?? '', From 5dc7f6c0f3d243d39fda45c97021e76a7a99d026 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 11 Jun 2024 14:21:29 +0200 Subject: [PATCH 19/19] fix: lint and typecheck --- src/libs/ReportUtils.ts | 12 ++++++++++++ src/libs/actions/Report.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 4de976aaf160..740ed75b7e1f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5437,6 +5437,17 @@ function shouldReportBeInOptionList({ return true; } +/** + * Returns the system report from the list of reports. + */ +function getSystemChat(): OnyxEntry { + if (!allReports) { + return null; + } + + return Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) ?? null; +} + /** * Attempts to find a report in onyx with the provided list of participants. Does not include threads, task, expense, room, and policy expense chat. */ @@ -7058,6 +7069,7 @@ export { getRoomWelcomeMessage, getRootParentReport, getRouteFromLink, + getSystemChat, getTaskAssigneeChatOnyxData, getTransactionDetails, getTransactionReportName, diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index daf1e5c29d81..46845dce8a1e 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2014,7 +2014,7 @@ function navigateToConciergeChat(shouldDismissModal = false, checkIfCurrentPageA function navigateToSystemChat() { const systemChatReport = ReportUtils.getSystemChat(); - if (systemChatReport && systemChatReport.reportID) { + if (systemChatReport?.reportID) { Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(systemChatReport.reportID)); } }