diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 88bf212ca0a3..6099b06c70eb 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2,7 +2,7 @@ import {format as timezoneFormat, utcToZonedTime} from 'date-fns-tz'; import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import Str from 'expensify-common/lib/str'; import isEmpty from 'lodash/isEmpty'; -import {DeviceEventEmitter, InteractionManager} from 'react-native'; +import {DeviceEventEmitter, InteractionManager, Linking} from 'react-native'; import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {NullishDeep} from 'react-native-onyx/lib/types'; @@ -127,6 +127,14 @@ const allReports: OnyxCollection = {}; let conciergeChatReportID: string | undefined; const typingWatchTimers: Record = {}; +let reportIDDeeplinkedFromOldDot: string | undefined; +Linking.getInitialURL().then((url) => { + const params = new URLSearchParams(url ?? ''); + const exitToRoute = params.get('exitTo') ?? ''; + const {reportID} = ReportUtils.parseReportRouteParams(exitToRoute); + reportIDDeeplinkedFromOldDot = reportID; +}); + /** Get the private pusher channel name for a Report. */ function getReportChannelName(reportID: string): string { return `${CONST.PUSHER.PRIVATE_REPORT_CHANNEL_PREFIX}${reportID}${CONFIG.PUSHER.SUFFIX}`; @@ -343,6 +351,7 @@ function addActions(reportID: string, text = '', file?: File) { timezone?: string; shouldAllowActionableMentionWhispers?: boolean; clientCreatedTime?: string; + isOldDotConciergeChat?: boolean; }; const parameters: AddCommentOrAttachementParameters = { @@ -355,6 +364,10 @@ function addActions(reportID: string, text = '', file?: File) { clientCreatedTime: file ? attachmentAction?.created : reportCommentAction?.created, }; + if (reportIDDeeplinkedFromOldDot === reportID && report?.participantAccountIDs?.length === 1 && Number(report.participantAccountIDs?.[0]) === CONST.ACCOUNT_ID.CONCIERGE) { + parameters.isOldDotConciergeChat = true; + } + const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE,