From ef3052a628a220d1b2a6bca40cae45cc5e666026 Mon Sep 17 00:00:00 2001 From: Linh Date: Fri, 27 Feb 2026 09:56:18 +0700 Subject: [PATCH 1/2] refactor: make navigateToConciergeChat pure function receive currentUserAccountID --- .../MoneyRequestReceiptView.tsx | 6 ++--- src/components/ReportActionItem/TaskView.tsx | 2 +- .../WalletStatementModal/index.native.tsx | 4 +-- src/components/WalletStatementModal/index.tsx | 2 +- .../walletNavigationUtils.ts | 4 +-- src/libs/actions/Link.ts | 4 ++- src/libs/actions/Report/index.ts | 25 ++++++++++++------- src/libs/actions/Task.ts | 4 +-- src/pages/ConciergePage.tsx | 3 ++- src/pages/Debug/Report/DebugReportPage.tsx | 6 ++++- .../NonUSD/Finish/index.tsx | 4 ++- .../ConnectBankAccount/ConnectBankAccount.tsx | 4 ++- .../components/FinishChatCard.tsx | 5 +++- src/pages/inbox/ReportScreen.tsx | 6 ++--- .../report/ReportActionItemParentAction.tsx | 6 +++-- src/pages/settings/AboutPage/AboutPage.tsx | 7 ++++-- .../BillingBanner/PreTrialBillingBanner.tsx | 4 ++- .../SubscriptionSettings/index.tsx | 5 +++- .../Subscription/TaxExemptActions/index.tsx | 6 +++-- .../workspace/WorkspaceMoreFeaturesPage.tsx | 6 +++-- .../WorkspaceCompanyCardsFeedPendingPage.tsx | 4 ++- .../companyCards/addNew/AddNewCardPage.tsx | 4 ++- .../expensifyCard/WorkspaceCardsListLabel.tsx | 4 ++- 23 files changed, 83 insertions(+), 42 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReceiptView.tsx b/src/components/ReportActionItem/MoneyRequestReceiptView.tsx index e77ff216c5f5d..d895a01166317 100644 --- a/src/components/ReportActionItem/MoneyRequestReceiptView.tsx +++ b/src/components/ReportActionItem/MoneyRequestReceiptView.tsx @@ -130,7 +130,7 @@ function MoneyRequestReceiptView({report, readonly = false, updatedTransaction, const didReceiptScanSucceed = hasReceipt && didReceiptScanSucceedTransactionUtils(transaction); const isInvoice = isInvoiceReport(moneyRequestReport); const isChatReportArchived = useReportIsArchived(moneyRequestReport?.chatReportID); - const {login: currentUserLogin} = useCurrentUserPersonalDetails(); + const {login: currentUserLogin, accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); // Flags for allowing or disallowing editing an expense // Used for non-restricted fields such as: description, category, tag, billable, etc... @@ -266,7 +266,7 @@ function MoneyRequestReceiptView({report, readonly = false, updatedTransaction, } if (transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) { if (chatReport?.reportID && getCreationReportErrors(chatReport)) { - navigateToConciergeChatAndDeleteReport(chatReport.reportID, conciergeReportID, true, true); + navigateToConciergeChatAndDeleteReport(chatReport.reportID, conciergeReportID, currentUserAccountID, true, true); return; } if (parentReportAction) { @@ -303,7 +303,7 @@ function MoneyRequestReceiptView({report, readonly = false, updatedTransaction, if (isInNarrowPaneModal) { Navigation.goBack(); } - navigateToConciergeChatAndDeleteReport(report.reportID, conciergeReportID, true, true); + navigateToConciergeChatAndDeleteReport(report.reportID, conciergeReportID, currentUserAccountID, true, true); } }; diff --git a/src/components/ReportActionItem/TaskView.tsx b/src/components/ReportActionItem/TaskView.tsx index 45b41beb1b0a5..de9160b0e8181 100644 --- a/src/components/ReportActionItem/TaskView.tsx +++ b/src/components/ReportActionItem/TaskView.tsx @@ -105,7 +105,7 @@ function TaskView({report, parentReport, action}: TaskViewProps) { clearTaskErrors(report, conciergeReportID)} + onClose={() => clearTaskErrors(report, conciergeReportID, accountID)} errorRowStyles={styles.ph5} > diff --git a/src/components/WalletStatementModal/index.native.tsx b/src/components/WalletStatementModal/index.native.tsx index dfea54957b6aa..00466926f0fd7 100644 --- a/src/components/WalletStatementModal/index.native.tsx +++ b/src/components/WalletStatementModal/index.native.tsx @@ -30,12 +30,12 @@ function WalletStatementModal({statementPageURL}: WalletStatementProps) { return; } - handleWalletStatementNavigation(conciergeReportID, type, url); + handleWalletStatementNavigation(conciergeReportID, session?.accountID, type, url); } catch (error) { console.error('Error parsing message from WebView:', error); } }, - [conciergeReportID], + [conciergeReportID, session?.accountID], ); return ( diff --git a/src/components/WalletStatementModal/index.tsx b/src/components/WalletStatementModal/index.tsx index 821c5e1f01cc0..e47de6a1d7e10 100644 --- a/src/components/WalletStatementModal/index.tsx +++ b/src/components/WalletStatementModal/index.tsx @@ -20,7 +20,7 @@ function WalletStatementModal({statementPageURL}: WalletStatementProps) { const navigate = (event: MessageEvent) => { const {data} = event; const {type, url} = data || {}; - handleWalletStatementNavigation(conciergeReportID, type, url); + handleWalletStatementNavigation(conciergeReportID, session?.accountID, type, url); }; return ( diff --git a/src/components/WalletStatementModal/walletNavigationUtils.ts b/src/components/WalletStatementModal/walletNavigationUtils.ts index d419f7d4fca2c..21bebdd6a3443 100644 --- a/src/components/WalletStatementModal/walletNavigationUtils.ts +++ b/src/components/WalletStatementModal/walletNavigationUtils.ts @@ -8,13 +8,13 @@ import type {Route} from '@src/ROUTES'; /** * Handles navigation for wallet statement actions */ -function handleWalletStatementNavigation(conciergeReportID: string | undefined, type?: string, url?: string): void { +function handleWalletStatementNavigation(conciergeReportID: string | undefined, currentUserAccountID: number | undefined, type?: string, url?: string): void { if (!type || (type !== CONST.WALLET.WEB_MESSAGE_TYPE.STATEMENT && type !== CONST.WALLET.WEB_MESSAGE_TYPE.CONCIERGE)) { return; } if (type === CONST.WALLET.WEB_MESSAGE_TYPE.CONCIERGE) { - navigateToConciergeChat(conciergeReportID); + navigateToConciergeChat(conciergeReportID, currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID); return; } diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 8e951001b8936..7103ce7e8e610 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -45,11 +45,13 @@ Onyx.connectWithoutView({ }); let currentUserEmail = ''; +let currentUserAccountID = -1; // Use connectWithoutView since this is to open an external link and doesn't affect any UI Onyx.connectWithoutView({ key: ONYXKEYS.SESSION, callback: (value) => { currentUserEmail = value?.email ?? ''; + currentUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID; }, }); @@ -333,7 +335,7 @@ function openReportFromDeepLink(url: string, reports: OnyxCollection, is Navigation.navigate(lastAccessedReportRoute, {forceReplace: Navigation.getTopmostReportId() === reportID}); return; } - navigateToConciergeChat(conciergeReportID, false, () => true); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false, () => true); return; } diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 3b98fdcdef542..c5ff67b0c9f68 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -3198,6 +3198,7 @@ function updateWriteCapability(report: Report, newValue: WriteCapability) { */ function navigateToConciergeChat( conciergeReportID: string | undefined, + currentUserAccountID: number, shouldDismissModal = false, checkIfCurrentPageActive = () => true, linkToOptions?: LinkToOptions, @@ -3213,7 +3214,7 @@ function navigateToConciergeChat( if (!checkIfCurrentPageActive()) { return; } - navigateToAndOpenReport([CONST.EMAIL.CONCIERGE], deprecatedCurrentUserAccountID, shouldDismissModal); + navigateToAndOpenReport([CONST.EMAIL.CONCIERGE], currentUserAccountID, shouldDismissModal); }); } else if (shouldDismissModal) { Navigation.dismissModalWithReport({reportID: conciergeReportID, reportActionID}); @@ -3664,21 +3665,27 @@ function deleteReport(reportID: string | undefined, shouldDeleteChildReports = f /** * @param reportID The reportID of the policy report (workspace room) */ -function navigateToConciergeChatAndDeleteReport(reportID: string | undefined, conciergeReportID: string | undefined, shouldPopToTop = false, shouldDeleteChildReports = false) { +function navigateToConciergeChatAndDeleteReport( + reportID: string | undefined, + conciergeReportID: string | undefined, + currentUserAccountID: number, + shouldPopToTop = false, + shouldDeleteChildReports = false, +) { // Dismiss the current report screen and replace it with Concierge Chat if (shouldPopToTop) { Navigation.popToSidebar(); } else { Navigation.goBack(); } - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); // eslint-disable-next-line @typescript-eslint/no-deprecated InteractionManager.runAfterInteractions(() => { deleteReport(reportID, shouldDeleteChildReports); }); } -function clearCreateChatError(report: OnyxEntry, conciergeReportID: string | undefined) { +function clearCreateChatError(report: OnyxEntry, conciergeReportID: string | undefined, currentUserAccountID: number) { const metaData = getReportMetadata(report?.reportID); const isOptimisticReport = metaData?.isOptimisticReport; if (report?.errorFields?.createChat && !isOptimisticReport) { @@ -3686,7 +3693,7 @@ function clearCreateChatError(report: OnyxEntry, conciergeReportID: stri return; } - navigateToConciergeChatAndDeleteReport(report?.reportID, conciergeReportID, undefined, true); + navigateToConciergeChatAndDeleteReport(report?.reportID, conciergeReportID, currentUserAccountID, undefined, true); } /** @@ -4020,7 +4027,7 @@ function doneCheckingPublicRoom() { Onyx.set(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, false); } -function navigateToMostRecentReport(currentReport: OnyxEntry, conciergeReportID: string | undefined) { +function navigateToMostRecentReport(currentReport: OnyxEntry, conciergeReportID: string | undefined, currentUserAccountID: number) { const lastAccessedReportID = findLastAccessedReport(false, false, currentReport?.reportID)?.reportID; if (lastAccessedReportID) { @@ -4041,7 +4048,7 @@ function navigateToMostRecentReport(currentReport: OnyxEntry, conciergeR Navigation.goBack(); } - navigateToConciergeChat(conciergeReportID, false, () => true, {forceReplace: true}); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false, () => true, {forceReplace: true}); } } @@ -4111,7 +4118,7 @@ function leaveGroupChat(report: Report, shouldClearQuickAction: boolean, current }, ]; - navigateToMostRecentReport(report, conciergeReportID); + navigateToMostRecentReport(report, conciergeReportID, currentUserAccountID); API.write(WRITE_COMMANDS.LEAVE_GROUP_CHAT, {reportID}, {optimisticData, successData, failureData}); } @@ -4220,7 +4227,7 @@ function leaveRoom(report: Report, currentUserAccountID: number, conciergeReport return; } // In other cases, the report is deleted and we should move the user to another report. - navigateToMostRecentReport(report, conciergeReportID); + navigateToMostRecentReport(report, conciergeReportID, currentUserAccountID); } function buildInviteToRoomOnyxData(report: Report, inviteeEmailsToAccountIDs: InvitedEmailsToAccountIDs, formatPhoneNumber: LocaleContextProps['formatPhoneNumber']) { diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index e00ba5ea1f241..b81dccc2d5f51 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1273,7 +1273,7 @@ function canActionTask( return sessionAccountID === taskReport?.ownerAccountID || sessionAccountID === getTaskAssigneeAccountID(taskReport, parentReportAction); } -function clearTaskErrors(report: OnyxEntry, conciergeReportID: string | undefined) { +function clearTaskErrors(report: OnyxEntry, conciergeReportID: string | undefined, currentUserAccountID: number) { const reportID = report?.reportID; if (!reportID) { return; @@ -1283,7 +1283,7 @@ function clearTaskErrors(report: OnyxEntry, conciergeReportID: if (report?.pendingFields?.createChat === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, report.parentReportActionID ? {[report.parentReportActionID]: null} : {}); - navigateToConciergeChatAndDeleteReport(reportID, conciergeReportID); + navigateToConciergeChatAndDeleteReport(reportID, conciergeReportID, currentUserAccountID); return; } diff --git a/src/pages/ConciergePage.tsx b/src/pages/ConciergePage.tsx index 50f2f10779524..36c2337236be3 100644 --- a/src/pages/ConciergePage.tsx +++ b/src/pages/ConciergePage.tsx @@ -9,6 +9,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {confirmReadyToOpenApp} from '@libs/actions/App'; import {navigateToConciergeChat} from '@libs/actions/Report'; import Navigation from '@libs/Navigation/Navigation'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -33,7 +34,7 @@ function ConciergePage() { return; } - navigateToConciergeChat(conciergeReportID, true, () => !isUnmounted.current); + navigateToConciergeChat(conciergeReportID, session.accountID ?? CONST.DEFAULT_NUMBER_ID, true, () => !isUnmounted.current); }); } else { Navigation.navigate(ROUTES.INBOX); diff --git a/src/pages/Debug/Report/DebugReportPage.tsx b/src/pages/Debug/Report/DebugReportPage.tsx index 8c8f00e1831cc..e644eed6f4edd 100644 --- a/src/pages/Debug/Report/DebugReportPage.tsx +++ b/src/pages/Debug/Report/DebugReportPage.tsx @@ -5,6 +5,7 @@ import Button from '@components/Button'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -70,6 +71,7 @@ function DebugReportPage({ const [priorityMode] = useOnyx(ONYXKEYS.NVP_PRIORITY_MODE); const [betas] = useOnyx(ONYXKEYS.BETAS); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const transactionID = DebugUtils.getTransactionID(report, reportActions); const isReportArchived = useReportIsArchived(reportID); @@ -162,7 +164,7 @@ function DebugReportPage({ Debug.setDebugData(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, data); }} onDelete={() => { - navigateToConciergeChatAndDeleteReport(reportID, conciergeReportID, true, true); + navigateToConciergeChatAndDeleteReport(reportID, conciergeReportID, currentUserAccountID, true, true); }} validate={DebugUtils.validateReportDraftProperty} > @@ -223,6 +225,8 @@ function DebugReportPage({ transactionID, translate, icons.Eye, + currentUserAccountID, + conciergeReportID, ], ); diff --git a/src/pages/ReimbursementAccount/NonUSD/Finish/index.tsx b/src/pages/ReimbursementAccount/NonUSD/Finish/index.tsx index 9ef6eebf83149..3541ea664683d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Finish/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Finish/index.tsx @@ -6,6 +6,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; import Text from '@components/Text'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -22,6 +23,7 @@ function Finish() { const {shouldUseNarrowLayout} = useResponsiveLayout(); const icons = useMemoizedLazyExpensifyIcons(['NewWindow', 'Shield', 'ChatBubble']); const illustrations = useMemoizedLazyIllustrations(['ConciergeBubble', 'ShieldYellow']); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); @@ -30,7 +32,7 @@ function Finish() { const handleBackButtonPress = () => { Navigation.goBack(); }; - const handleNavigateToConciergeChat = () => navigateToConciergeChat(conciergeReportID, true); + const handleNavigateToConciergeChat = () => navigateToConciergeChat(conciergeReportID, currentUserAccountID, true); return ( navigateToConciergeChat(conciergeReportID, true); + const handleNavigateToConciergeChat = () => navigateToConciergeChat(conciergeReportID, currentUserAccountID, true); const bankAccountState = reimbursementAccount?.achData?.state ?? ''; // If a user tries to navigate directly to the validate page we'll show them the EnableStep diff --git a/src/pages/ReimbursementAccount/USD/ConnectBankAccount/components/FinishChatCard.tsx b/src/pages/ReimbursementAccount/USD/ConnectBankAccount/components/FinishChatCard.tsx index 610178b1eb39b..eae2ea3d29b76 100644 --- a/src/pages/ReimbursementAccount/USD/ConnectBankAccount/components/FinishChatCard.tsx +++ b/src/pages/ReimbursementAccount/USD/ConnectBankAccount/components/FinishChatCard.tsx @@ -3,6 +3,7 @@ import MenuItem from '@components/MenuItem'; import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; import Text from '@components/Text'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -32,9 +33,11 @@ function FinishChatCard({requiresTwoFactorAuth, reimbursementAccount, setUSDBank const styles = useThemeStyles(); const {shouldUseNarrowLayout} = useResponsiveLayout(); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const policyID = reimbursementAccount?.achData?.policyID; const shouldShowResetModal = reimbursementAccount?.shouldShowResetModal ?? false; - const handleNavigateToConciergeChat = () => navigateToConciergeChat(conciergeReportID, true, undefined, undefined, reimbursementAccount?.achData?.ACHRequestReportActionID); + + const handleNavigateToConciergeChat = () => navigateToConciergeChat(conciergeReportID, currentUserAccountID, true, undefined, reimbursementAccount?.achData?.ACHRequestReportActionID); const icons = useMemoizedLazyExpensifyIcons(['ChatBubble', 'Pencil', 'RotateLeft'] as const); const illustrations = useMemoizedLazyIllustrations(['ConciergeBubble']); diff --git a/src/pages/inbox/ReportScreen.tsx b/src/pages/inbox/ReportScreen.tsx index 195212de3b87e..c8a8e2e012736 100644 --- a/src/pages/inbox/ReportScreen.tsx +++ b/src/pages/inbox/ReportScreen.tsx @@ -818,7 +818,7 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr } Navigation.isNavigationReady().then(() => { - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); }); return; } @@ -870,9 +870,9 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr // Fallback to Concierge Navigation.isNavigationReady().then(() => { - navigateToConciergeChat(conciergeReportID); + navigateToConciergeChat(conciergeReportID, currentUserAccountID); }); - }, [reportWasDeleted, isFocused, deletedReportParentID, conciergeReportID]); + }, [reportWasDeleted, isFocused, deletedReportParentID, conciergeReportID, currentUserAccountID]); useEffect(() => { if (!isValidReportIDFromPath(reportIDFromRoute)) { diff --git a/src/pages/inbox/report/ReportActionItemParentAction.tsx b/src/pages/inbox/report/ReportActionItemParentAction.tsx index 62b2b309fb39b..cce2798dce5e7 100644 --- a/src/pages/inbox/report/ReportActionItemParentAction.tsx +++ b/src/pages/inbox/report/ReportActionItemParentAction.tsx @@ -4,6 +4,7 @@ import {View} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import useAncestors from '@hooks/useAncestors'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -112,6 +113,7 @@ function ReportActionItemParentAction({ const {isInNarrowPaneModal} = useResponsiveLayout(); const transactionID = isMoneyRequestAction(action) && getOriginalMessage(action)?.IOUTransactionID; const [allBetas] = useOnyx(ONYXKEYS.BETAS); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const getLinkedTransactionRouteError = useCallback((transaction: OnyxEntry) => { return transaction?.errorFields?.route; @@ -168,7 +170,7 @@ function ReportActionItemParentAction({ report?.errorFields?.createChatThread ?? (report?.errorFields?.createChat ? getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage') : null) } errorRowStyles={[styles.ml10, styles.mr2]} - onClose={() => navigateToConciergeChatAndDeleteReport(report?.reportID, conciergeReportID, undefined, true)} + onClose={() => navigateToConciergeChatAndDeleteReport(report?.reportID, conciergeReportID, currentUserAccountID, undefined, true)} > {ancestors.map((ancestor) => { const {report: ancestorReport, reportAction: ancestorReportAction} = ancestor; @@ -193,7 +195,7 @@ function ReportActionItemParentAction({ pendingAction={ancestorReport?.pendingFields?.addWorkspaceRoom ?? ancestorReport?.pendingFields?.createChat} errors={ancestorReport?.errorFields?.addWorkspaceRoom ?? ancestorReport?.errorFields?.createChat} errorRowStyles={[styles.ml10, styles.mr2]} - onClose={() => navigateToConciergeChatAndDeleteReport(ancestorReport.reportID, conciergeReportID)} + onClose={() => navigateToConciergeChatAndDeleteReport(ancestorReport.reportID, conciergeReportID, currentUserAccountID)} > {shouldDisplayThreadDivider && ( { @@ -104,7 +107,7 @@ function AboutPage() { translationKey: 'initialSettingsPage.aboutPage.reportABug', icon: icons.Bug, sentryLabel: CONST.SENTRY_LABEL.SETTINGS_ABOUT.REPORT_A_BUG, - action: waitForNavigate(() => navigateToConciergeChat(conciergeReportID, false)), + action: waitForNavigate(() => navigateToConciergeChat(conciergeReportID, currentUserAccountID, false)), }, ]; @@ -129,7 +132,7 @@ function AboutPage() { wrapperStyle: [styles.sectionMenuItemTopDescription], sentryLabel, })); - }, [icons, styles, translate, waitForNavigate, conciergeReportID]); + }, [icons, styles, translate, waitForNavigate, conciergeReportID, currentUserAccountID]); const overlayContent = useCallback( () => ( diff --git a/src/pages/settings/Subscription/CardSection/BillingBanner/PreTrialBillingBanner.tsx b/src/pages/settings/Subscription/CardSection/BillingBanner/PreTrialBillingBanner.tsx index cf5a494e4fb57..81cb2cf2812f4 100644 --- a/src/pages/settings/Subscription/CardSection/BillingBanner/PreTrialBillingBanner.tsx +++ b/src/pages/settings/Subscription/CardSection/BillingBanner/PreTrialBillingBanner.tsx @@ -1,6 +1,7 @@ import React from 'react'; import {View} from 'react-native'; import RenderHTML from '@components/RenderHTML'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -18,12 +19,13 @@ function PreTrialBillingBanner() { const illustrations = useMemoizedLazyIllustrations(['TreasureChest']); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const navigateToChat = () => { const reportUsedForOnboarding = getChatUsedForOnboarding(onboarding, conciergeReportID); if (!reportUsedForOnboarding) { - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); return; } diff --git a/src/pages/settings/Subscription/SubscriptionSettings/index.tsx b/src/pages/settings/Subscription/SubscriptionSettings/index.tsx index ceb8f4edaec24..e7df8b493deaf 100644 --- a/src/pages/settings/Subscription/SubscriptionSettings/index.tsx +++ b/src/pages/settings/Subscription/SubscriptionSettings/index.tsx @@ -13,6 +13,7 @@ import RenderHTML from '@components/RenderHTML'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useEnvironment from '@hooks/useEnvironment'; import useHasTeam2025Pricing from '@hooks/useHasTeam2025Pricing'; import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; @@ -60,9 +61,11 @@ function SubscriptionSettings() { const possibleCostSavings = useSubscriptionPossibleCostSavings(); const {isActingAsDelegate} = useDelegateNoAccessState(); const {showDelegateNoAccessModal} = useDelegateNoAccessActions(); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const isAnnual = privateSubscription?.type === CONST.SUBSCRIPTION.TYPE.ANNUAL; const [privateTaxExempt] = useOnyx(ONYXKEYS.NVP_PRIVATE_TAX_EXEMPT); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const isExpensifyCodeApplied = !!privateSubscription?.expensifyCode; const shouldShowExpensifyCodeSection = !privateSubscription?.isSecretPromoCode; const subscriptionPrice = getSubscriptionPrice(subscriptionPlan, preferredCurrency, privateSubscription?.type, hasTeam2025Pricing); @@ -284,7 +287,7 @@ function SubscriptionSettings() { shouldShowRightIcon onPress={() => { requestTaxExempt(); - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); }} icon={icons.Coins} wrapperStyle={styles.sectionMenuItemTopDescription} diff --git a/src/pages/settings/Subscription/TaxExemptActions/index.tsx b/src/pages/settings/Subscription/TaxExemptActions/index.tsx index 4ae8769d21dba..7b0dde253b9b1 100644 --- a/src/pages/settings/Subscription/TaxExemptActions/index.tsx +++ b/src/pages/settings/Subscription/TaxExemptActions/index.tsx @@ -2,6 +2,7 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; import ThreeDotsMenu from '@components/ThreeDotsMenu'; import type ThreeDotsMenuProps from '@components/ThreeDotsMenu/types'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -21,6 +22,7 @@ function TaxExemptActions() { const {translate} = useLocalize(); const icons = useMemoizedLazyExpensifyIcons(['Coins']); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const overflowMenu: ThreeDotsMenuProps['menuItems'] = useMemo( () => [ @@ -30,11 +32,11 @@ function TaxExemptActions() { text: translate('subscription.details.taxExempt'), onSelected: () => { requestTaxExempt(); - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); }, }, ], - [translate, icons.Coins, conciergeReportID], + [translate, icons.Coins, conciergeReportID, currentUserAccountID], ); return ( diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 84fa8adcd2caf..4eb209429ee1e 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -8,6 +8,7 @@ import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; import Text from '@components/Text'; import useCardFeeds from '@hooks/useCardFeeds'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useDefaultFundID from '@hooks/useDefaultFundID'; import useIsPolicyConnectedToUberReceiptPartner from '@hooks/useIsPolicyConnectedToUberReceiptPartner'; import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; @@ -97,6 +98,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro selector: filterInactiveCards, }); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const isUberConnected = useIsPolicyConnectedToUberReceiptPartner({policyID}); const [cardFeeds] = useCardFeeds(policyID); const [isOrganizeWarningModalOpen, setIsOrganizeWarningModalOpen] = useState(false); @@ -694,7 +696,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro isVisible={isDisableExpensifyCardWarningModalOpen} onConfirm={() => { setIsDisableExpensifyCardWarningModalOpen(false); - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); }} onCancel={() => setIsDisableExpensifyCardWarningModalOpen(false)} prompt={translate('workspace.moreFeatures.expensifyCard.disableCardPrompt')} @@ -706,7 +708,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro isVisible={isDisableCompanyCardsWarningModalOpen} onConfirm={() => { setIsDisableCompanyCardsWarningModalOpen(false); - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); }} onCancel={() => setIsDisableCompanyCardsWarningModalOpen(false)} prompt={translate('workspace.moreFeatures.companyCards.disableCardPrompt')} diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardsFeedPendingPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardsFeedPendingPage.tsx index ed2c965987306..e6da9beeaaaa0 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardsFeedPendingPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardsFeedPendingPage.tsx @@ -4,6 +4,7 @@ import ScrollView from '@components/ScrollView'; import CardRowSkeleton from '@components/Skeletons/CardRowSkeleton'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -18,6 +19,7 @@ function WorkspaceCompanyCardsFeedPendingPage() { const styles = useThemeStyles(); const {CompanyCardsPendingState} = useMemoizedLazyIllustrations(['CompanyCardsPendingState']); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); return ( @@ -32,7 +34,7 @@ function WorkspaceCompanyCardsFeedPendingPage() { > {translate('workspace.moreFeatures.companyCards.pendingFeedDescription')} - navigateToConciergeChat(conciergeReportID, false)}> {CONST.CONCIERGE_CHAT_NAME}. + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false)}> {CONST.CONCIERGE_CHAT_NAME}. diff --git a/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx b/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx index 9a74267cd3137..8934c03d890b3 100644 --- a/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx +++ b/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx @@ -5,6 +5,7 @@ import ConfirmModal from '@components/ConfirmModal'; import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import ScreenWrapper from '@components/ScreenWrapper'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useIsBlockedToAddFeed from '@hooks/useIsBlockedToAddFeed'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -43,6 +44,7 @@ function AddNewCardPage({policy}: WithPolicyAndFullscreenLoadingProps) { const [isModalVisible, setIsModalVisible] = useState(false); const {translate} = useLocalize(); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {selector: isActingAsDelegateSelector}); @@ -148,7 +150,7 @@ function AddNewCardPage({policy}: WithPolicyAndFullscreenLoadingProps) { onCancel={() => setIsModalVisible(false)} onConfirm={() => { setIsModalVisible(false); - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); }} /> diff --git a/src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx b/src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx index a5d5fadae8ec0..923a1acc84377 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx @@ -10,6 +10,7 @@ import Popover from '@components/Popover'; import {PressableWithFeedback} from '@components/Pressable'; import Text from '@components/Text'; import useCurrencyForExpensifyCard from '@hooks/useCurrencyForExpensifyCard'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useDefaultFundID from '@hooks/useDefaultFundID'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; @@ -51,6 +52,7 @@ function WorkspaceCardsListLabel({type, value, style}: WorkspaceCardsListLabelPr const {translate} = useLocalize(); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const [isVisible, setVisible] = useState(false); const [anchorPosition, setAnchorPosition] = useState({top: 0, left: 0}); const anchorRef = useRef(null); @@ -90,7 +92,7 @@ function WorkspaceCardsListLabel({type, value, style}: WorkspaceCardsListLabelPr const requestLimitIncrease = () => { requestExpensifyCardLimitIncrease(cardSettings?.paymentBankAccountID); setVisible(false); - navigateToConciergeChat(conciergeReportID, false); + navigateToConciergeChat(conciergeReportID, currentUserAccountID, false); }; const isCurrentBalanceType = type === CONST.WORKSPACE_CARDS_LIST_LABEL_TYPE.CURRENT_BALANCE; From 7f99f0632e00de8d7be312a6f075604dc8b1eaca Mon Sep 17 00:00:00 2001 From: Linh Date: Sun, 1 Mar 2026 14:41:45 +0700 Subject: [PATCH 2/2] refactor: make navigateToConciergeChat pure function receive currentUserAccountID --- .../HTMLRenderers/ConciergeLinkRenderer.tsx | 4 +- .../components/FinishChatCard.tsx | 3 +- .../inbox/report/ReportActionItemCreated.tsx | 4 +- tests/actions/ReportTest.ts | 37 ++++++++++--------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ConciergeLinkRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ConciergeLinkRenderer.tsx index 9274ea94f0b40..c1e78b84aa601 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ConciergeLinkRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ConciergeLinkRenderer.tsx @@ -4,6 +4,7 @@ import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-ht import {TNodeChildrenRenderer} from 'react-native-render-html'; import * as HTMLEngineUtils from '@components/HTMLEngineProvider/htmlEngineUtils'; import Text from '@components/Text'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useEnterKeyHandler from '@hooks/useEnterKeyHandler'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -16,12 +17,13 @@ type ConciergeLinkRendererProps = CustomRendererProps; function ConciergeLinkRenderer({tnode, style}: ConciergeLinkRendererProps) { const styles = useThemeStyles(); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); /** * Simple wrapper to create a stable reference without passing event args to navigation function. */ const navigateToConciergeChat = () => { - navigateToConciergeChatAction(conciergeReportID, false); + navigateToConciergeChatAction(conciergeReportID, currentUserAccountID, false); }; // Define link style based on context diff --git a/src/pages/ReimbursementAccount/USD/ConnectBankAccount/components/FinishChatCard.tsx b/src/pages/ReimbursementAccount/USD/ConnectBankAccount/components/FinishChatCard.tsx index eae2ea3d29b76..af681a3d65279 100644 --- a/src/pages/ReimbursementAccount/USD/ConnectBankAccount/components/FinishChatCard.tsx +++ b/src/pages/ReimbursementAccount/USD/ConnectBankAccount/components/FinishChatCard.tsx @@ -37,7 +37,8 @@ function FinishChatCard({requiresTwoFactorAuth, reimbursementAccount, setUSDBank const policyID = reimbursementAccount?.achData?.policyID; const shouldShowResetModal = reimbursementAccount?.shouldShowResetModal ?? false; - const handleNavigateToConciergeChat = () => navigateToConciergeChat(conciergeReportID, currentUserAccountID, true, undefined, reimbursementAccount?.achData?.ACHRequestReportActionID); + const handleNavigateToConciergeChat = () => + navigateToConciergeChat(conciergeReportID, currentUserAccountID, true, undefined, undefined, reimbursementAccount?.achData?.ACHRequestReportActionID); const icons = useMemoizedLazyExpensifyIcons(['ChatBubble', 'Pencil', 'RotateLeft'] as const); const illustrations = useMemoizedLazyIllustrations(['ConciergeBubble']); diff --git a/src/pages/inbox/report/ReportActionItemCreated.tsx b/src/pages/inbox/report/ReportActionItemCreated.tsx index 4d6d4666c98d3..3fae4c19aca79 100644 --- a/src/pages/inbox/report/ReportActionItemCreated.tsx +++ b/src/pages/inbox/report/ReportActionItemCreated.tsx @@ -4,6 +4,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import ReportActionAvatars from '@components/ReportActionAvatars'; import ReportWelcomeText from '@components/ReportWelcomeText'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -31,6 +32,7 @@ function ReportActionItemCreated({reportID, policyID}: ReportActionItemCreatedPr const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); + const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); if (!isChatReport(report)) { return null; @@ -43,7 +45,7 @@ function ReportActionItemCreated({reportID, policyID}: ReportActionItemCreatedPr pendingAction={report?.pendingFields?.addWorkspaceRoom ?? report?.pendingFields?.createChat} errors={report?.errorFields?.addWorkspaceRoom ?? report?.errorFields?.createChat} errorRowStyles={[styles.ml10, styles.mr2]} - onClose={() => clearCreateChatError(report, conciergeReportID)} + onClose={() => clearCreateChatError(report, conciergeReportID, currentUserAccountID)} > diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 3a6edbf75ecde..a8449fa375641 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -275,6 +275,7 @@ describe('actions/Report', () => { }); it('clearCreateChatError should not delete the report if it is not optimistic report', () => { + const TEST_USER_ACCOUNT_ID = 1; const REPORT: OnyxTypes.Report = {...createRandomReport(1, undefined), errorFields: {createChat: {error: 'error'}}}; const REPORT_METADATA: OnyxTypes.ReportMetadata = {isOptimisticReport: false}; const CONCIERGE_REPORT_ID = '123456'; @@ -284,7 +285,7 @@ describe('actions/Report', () => { return waitForBatchedUpdates() .then(() => { - Report.clearCreateChatError(REPORT, CONCIERGE_REPORT_ID); + Report.clearCreateChatError(REPORT, CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID); return waitForBatchedUpdates(); }) .then( @@ -3617,6 +3618,7 @@ describe('actions/Report', () => { describe('navigateToConciergeChat', () => { const CONCIERGE_REPORT_ID = '123456'; + const TEST_USER_ACCOUNT_ID = 1; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const mockNavigation: {navigate: jest.Mock; dismissModalWithReport: jest.Mock} = jest.requireMock('@libs/Navigation/Navigation'); @@ -3632,7 +3634,7 @@ describe('actions/Report', () => { await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, CONCIERGE_REPORT_ID); await waitForBatchedUpdates(); - Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, false); + Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID, false); await waitForBatchedUpdates(); @@ -3643,7 +3645,7 @@ describe('actions/Report', () => { await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, CONCIERGE_REPORT_ID); await waitForBatchedUpdates(); - Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, true); + Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID, true); await waitForBatchedUpdates(); @@ -3658,7 +3660,7 @@ describe('actions/Report', () => { // When conciergeReportID is undefined, the function uses onServerDataReady() // which is async. We're testing that it doesn't throw and handles the case properly. expect(() => { - Report.navigateToConciergeChat(undefined, false); + Report.navigateToConciergeChat(undefined, TEST_USER_ACCOUNT_ID, false); }).not.toThrow(); }); @@ -3667,7 +3669,7 @@ describe('actions/Report', () => { await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, CONCIERGE_REPORT_ID); await waitForBatchedUpdates(); - Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, true, undefined, undefined, reportActionID); + Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID, true, undefined, undefined, reportActionID); await waitForBatchedUpdates(); @@ -3682,7 +3684,7 @@ describe('actions/Report', () => { await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, CONCIERGE_REPORT_ID); await waitForBatchedUpdates(); - Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, false, undefined, linkToOptions); + Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID, false, undefined, linkToOptions); await waitForBatchedUpdates(); @@ -3696,7 +3698,7 @@ describe('actions/Report', () => { // Don't set CONCIERGE_REPORT_ID to simulate undefined state await waitForBatchedUpdates(); - Report.navigateToConciergeChat(undefined, false, checkIfCurrentPageActive); + Report.navigateToConciergeChat(undefined, TEST_USER_ACCOUNT_ID, false, checkIfCurrentPageActive); await waitForBatchedUpdates(); @@ -3711,7 +3713,7 @@ describe('actions/Report', () => { // When conciergeReportID is undefined (or null passed as undefined), // it should handle it gracefully expect(() => { - Report.navigateToConciergeChat(undefined, false); + Report.navigateToConciergeChat(undefined, TEST_USER_ACCOUNT_ID, false); }).not.toThrow(); }); @@ -3721,7 +3723,7 @@ describe('actions/Report', () => { // Empty string is falsy in JavaScript, so it should trigger the undefined path expect(() => { - Report.navigateToConciergeChat('', false); + Report.navigateToConciergeChat('', TEST_USER_ACCOUNT_ID, false); }).not.toThrow(); }); @@ -3733,7 +3735,7 @@ describe('actions/Report', () => { await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, CONCIERGE_REPORT_ID); await waitForBatchedUpdates(); - Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, true, checkIfCurrentPageActive, linkToOptions, reportActionID); + Report.navigateToConciergeChat(CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID, true, checkIfCurrentPageActive, linkToOptions, reportActionID); await waitForBatchedUpdates(); @@ -3750,7 +3752,7 @@ describe('actions/Report', () => { await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, onyxConciergeReportID); await waitForBatchedUpdates(); - Report.navigateToConciergeChat(providedConciergeReportID, false); + Report.navigateToConciergeChat(providedConciergeReportID, TEST_USER_ACCOUNT_ID, false); await waitForBatchedUpdates(); @@ -3762,6 +3764,7 @@ describe('actions/Report', () => { describe('navigateToConciergeChatAndDeleteReport', () => { const CONCIERGE_REPORT_ID = '123456'; const REPORT_ID = '789'; + const TEST_USER_ACCOUNT_ID = 1; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const mockNavigation: {navigate: jest.Mock; dismissModalWithReport: jest.Mock; goBack: jest.Mock; popToSidebar: jest.Mock} = jest.requireMock('@libs/Navigation/Navigation'); @@ -3780,7 +3783,7 @@ describe('actions/Report', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, testReport); await waitForBatchedUpdates(); - Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, CONCIERGE_REPORT_ID); + Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID); await waitForBatchedUpdates(); @@ -3794,7 +3797,7 @@ describe('actions/Report', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, testReport); await waitForBatchedUpdates(); - Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, CONCIERGE_REPORT_ID, true); + Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID, true); await waitForBatchedUpdates(); @@ -3807,7 +3810,7 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.navigateToConciergeChatAndDeleteReport(undefined, CONCIERGE_REPORT_ID); + Report.navigateToConciergeChatAndDeleteReport(undefined, CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID); }).not.toThrow(); }); @@ -3816,7 +3819,7 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, undefined); + Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, undefined, TEST_USER_ACCOUNT_ID); }).not.toThrow(); await waitForBatchedUpdates(); @@ -3830,7 +3833,7 @@ describe('actions/Report', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, testReport); await waitForBatchedUpdates(); - Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, CONCIERGE_REPORT_ID, false, true); + Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID, false, true); await waitForBatchedUpdates(); @@ -3843,7 +3846,7 @@ describe('actions/Report', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, testReport); await waitForBatchedUpdates(); - Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, CONCIERGE_REPORT_ID, true, true); + Report.navigateToConciergeChatAndDeleteReport(REPORT_ID, CONCIERGE_REPORT_ID, TEST_USER_ACCOUNT_ID, true, true); await waitForBatchedUpdates();