diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5749e241b6fb..14c5c692d67f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -45,7 +45,6 @@ import type { OriginalMessageCreated, OriginalMessageReimbursementDequeued, OriginalMessageRenamed, - OriginalMessageRoomChangeLog, PaymentMethodType, ReimbursementDeQueuedMessage, } from '@src/types/onyx/OriginalMessage'; @@ -118,8 +117,6 @@ type SpendBreakdown = { type ParticipantDetails = [number, string, UserUtils.AvatarSource, UserUtils.AvatarSource]; -type OptimisticInviteReportAction = ReportActionBase & OriginalMessageRoomChangeLog; - type OptimisticAddCommentReportAction = Pick< ReportAction, | 'reportActionID' @@ -3378,44 +3375,6 @@ function getPolicyDescriptionText(policy: OnyxEntry): string { return parser.htmlToText(policy.description); } -/** Builds an optimistic reportAction for the invite message */ -function buildOptimisticInviteReportAction(invitedUserDisplayName: string, invitedUserID: number): OptimisticInviteReportAction { - const text = `${Localize.translateLocal('workspace.invite.invited')} ${invitedUserDisplayName}`; - const commentText = getParsedComment(text); - const parser = new ExpensiMark(); - const currentUser = allPersonalDetails?.[currentUserAccountID ?? -1]; - - return { - reportActionID: NumberUtils.rand64(), - actionName: CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM, - actorAccountID: currentUserAccountID, - person: [ - { - style: 'strong', - text: currentUser?.displayName ?? currentUserEmail, - type: 'TEXT', - }, - ], - automatic: false, - avatar: currentUser?.avatar ?? UserUtils.getDefaultAvatarURL(currentUserAccountID), - created: DateUtils.getDBTime(), - message: [ - { - type: CONST.REPORT.MESSAGE.TYPE.COMMENT, - html: commentText, - text: parser.htmlToText(commentText), - }, - ], - originalMessage: { - targetAccountIDs: [invitedUserID], - }, - isFirstItem: false, - pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, - shouldShow: true, - isOptimisticAction: true, - }; -} - function buildOptimisticAddCommentReportAction( text?: string, file?: FileObject, @@ -6764,7 +6723,6 @@ export { updateReportPreview, temporary_getMoneyRequestOptions, buildOptimisticInvoiceReport, - buildOptimisticInviteReportAction, getInvoiceChatByParticipants, shouldShowMerchantColumn, isCurrentUserInvoiceReceiver, @@ -6783,6 +6741,5 @@ export type { OptimisticTaskReportAction, OptionData, TransactionDetails, - OptimisticInviteReportAction, ParsingDetails, }; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index eb7b82800358..555bf2351d3c 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -41,7 +41,7 @@ import Permissions from '@libs/Permissions'; import * as PhoneNumber from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; -import type {OptimisticChatReport, OptimisticCreatedReportAction, OptimisticInviteReportAction, OptimisticIOUReportAction, TransactionDetails} from '@libs/ReportUtils'; +import type {OptimisticChatReport, OptimisticCreatedReportAction, OptimisticIOUReportAction, TransactionDetails} from '@libs/ReportUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import * as UserUtils from '@libs/UserUtils'; @@ -816,7 +816,6 @@ function buildOnyxDataForInvoice( isNewChatReport: boolean, transactionThreadReport: OptimisticChatReport, transactionThreadCreatedReportAction: OptimisticCreatedReportAction | EmptyObject, - inviteReportAction?: OptimisticInviteReportAction, policy?: OnyxEntry, policyTagList?: OnyxEntry, policyCategories?: OnyxEntry, @@ -840,12 +839,11 @@ function buildOnyxDataForInvoice( key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, value: transaction, }, - isNewChatReport && inviteReportAction + isNewChatReport ? { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`, value: { - [inviteReportAction.reportActionID]: inviteReportAction as ReportAction, [chatCreatedAction.reportActionID]: chatCreatedAction, [reportPreviewAction.reportActionID]: reportPreviewAction, }, @@ -1673,7 +1671,6 @@ function getSendInvoiceInformation( } // STEP 5: Build optimistic reportActions. - let inviteReportAction: OptimisticInviteReportAction | undefined; const [optimisticCreatedActionForChat, optimisticCreatedActionForIOUReport, iouAction, optimisticTransactionThread, optimisticCreatedActionForTransactionThread] = ReportUtils.buildOptimisticMoneyRequestEntities( optimisticInvoiceReport, @@ -1690,9 +1687,6 @@ function getSendInvoiceInformation( receiptObject, false, ); - if (isNewChatReport) { - inviteReportAction = ReportUtils.buildOptimisticInviteReportAction(receiver?.displayName ?? '', receiver.accountID ?? -1); - } const reportPreviewAction = ReportUtils.buildOptimisticReportPreview(chatReport, optimisticInvoiceReport, trimmedComment, optimisticTransaction); // STEP 6: Build Onyx Data @@ -1710,7 +1704,6 @@ function getSendInvoiceInformation( isNewChatReport, optimisticTransactionThread, optimisticCreatedActionForTransactionThread, - inviteReportAction, policy, policyTagList, policyCategories,