From b65a85ca4849d91104bfba924ac0e1a156f44151 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 16 Dec 2024 10:39:06 +0700 Subject: [PATCH 1/7] Add report action for deleting expenses --- src/CONST.ts | 2 ++ src/languages/en.ts | 2 ++ src/languages/params.ts | 6 ++++++ src/libs/ReportUtils.ts | 8 ++++++++ .../home/report/ContextMenu/ContextMenuActions.tsx | 2 ++ src/pages/home/report/PureReportActionItem.tsx | 2 ++ src/types/onyx/OriginalMessage.ts | 10 ++++++++++ 7 files changed, 32 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 204ccaccf394..93ec98c1f958 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1032,6 +1032,7 @@ const CONST = { CREATED: 'CREATED', DELEGATE_SUBMIT: 'DELEGATESUBMIT', // OldDot Action DELETED_ACCOUNT: 'DELETEDACCOUNT', // Deprecated OldDot Action + DELETED_TRANSACTION: 'DELETEDTRANSACTION', DISMISSED_VIOLATION: 'DISMISSEDVIOLATION', DONATION: 'DONATION', // Deprecated OldDot Action EXPORTED_TO_CSV: 'EXPORTCSV', // OldDot Action @@ -1087,6 +1088,7 @@ const CONST = { ADD_CUSTOM_UNIT: 'POLICYCHANGELOG_ADD_CUSTOM_UNIT', ADD_CUSTOM_UNIT_RATE: 'POLICYCHANGELOG_ADD_CUSTOM_UNIT_RATE', ADD_EMPLOYEE: 'POLICYCHANGELOG_ADD_EMPLOYEE', + DELETED_TRANSACTION: 'POLICYCHANGELOG_DELETED_TRANSACTION', ADD_INTEGRATION: 'POLICYCHANGELOG_ADD_INTEGRATION', ADD_REPORT_FIELD: 'POLICYCHANGELOG_ADD_REPORT_FIELD', ADD_TAG: 'POLICYCHANGELOG_ADD_TAG', diff --git a/src/languages/en.ts b/src/languages/en.ts index 66a83e719377..59111c1adb88 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -59,6 +59,7 @@ import type { DelegatorParams, DeleteActionParams, DeleteConfirmationParams, + DeleteTransactionParams, DidSplitAmountMessageParams, EditActionParams, ElectronicFundsParams, @@ -866,6 +867,7 @@ const translations = { canceled: 'Canceled', posted: 'Posted', deleteReceipt: 'Delete receipt', + deletedTransaction: ({amount, merchant}: DeleteTransactionParams) => `deleted an expense on this report, ${amount} - ${merchant}`, pendingMatchWithCreditCard: 'Receipt pending match with card transaction', pendingMatchWithCreditCardDescription: 'Receipt pending match with card transaction. Mark as cash to cancel.', markAsCash: 'Mark as cash', diff --git a/src/languages/params.ts b/src/languages/params.ts index eb592d751116..46f7db46dd4c 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -115,6 +115,11 @@ type RequestCountParams = { pendingReceipts: number; }; +type DeleteTransactionParams = { + amount: number; + merchant: string; +}; + type SettleExpensifyCardParams = { formattedAmount: string; }; @@ -703,6 +708,7 @@ export type { ReportArchiveReasonsRemovedFromPolicyParams, RequestAmountParams, RequestCountParams, + DeleteTransactionParams, RequestedAmountMessageParams, ResolutionConstraintsParams, RoomNameReservedErrorParams, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index eb728586f8f2..07ff4605d59b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4859,6 +4859,13 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) { return message; } +function getDeletedTransactionMessage(action: ReportAction) { + const deletedTransactionOriginalMessage = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + + const message = Localize.translateLocal('iou.deletedTransaction', {amount: deletedTransactionOriginalMessage.amount ?? 0, merchant: deletedTransactionOriginalMessage.merchant ?? ''}); + return message; +} + /** * @param iouReportID - the report ID of the IOU report the action belongs to * @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) @@ -8612,6 +8619,7 @@ export { getIOUForwardedMessage, getRejectedReportMessage, getWorkspaceNameUpdatedMessage, + getDeletedTransactionMessage, getReportAutomaticallySubmittedMessage, getIOUSubmittedMessage, getIcons, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index a31137e53c6a..9fda50a0f7be 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -472,6 +472,8 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETED_TRANSACTION) { + setClipboardMessage(ReportUtils.getDeletedTransactionMessage(reportAction)); } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''}; setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage})); diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 34dd2a9d1350..a1c75fdabb03 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -811,6 +811,8 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) { children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 0cb9a735aad4..bc86c6bc1b0b 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -370,6 +370,15 @@ type OriginalMessageModifiedExpense = { attendees?: string; }; +/** Model of the `deleted transaction` report action */ +type OriginalMessageDeletedTransaction = { + /** The merchant of the transaction */ + merchant?: string; + + /** The amount of the transaction */ + amount?: number; +}; + /** Model of `reimbursement queued` report action */ type OriginalMessageReimbursementQueued = { /** How is the payment getting reimbursed */ @@ -637,6 +646,7 @@ type OriginalMessageMap = { [CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL]: OriginalMessageCard; [CONST.REPORT.ACTIONS.TYPE.CARD_ASSIGNED]: OriginalMessageCard; [CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED]: OriginalMessageIntegrationSyncFailed; + [CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION]: OriginalMessageDeletedTransaction; } & OldDotOriginalMessageMap & { [T in ValueOf]: OriginalMessageChangeLog; } & { From f047de6dbae8f0eab447e77474d3133f0ba8eeb3 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 9 Jan 2025 23:29:01 +0700 Subject: [PATCH 2/7] fix deleted transaction message --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 ++ src/languages/params.ts | 2 +- src/libs/ReportUtils.ts | 8 ++++++-- src/types/onyx/OriginalMessage.ts | 3 +++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 8bf381629077..55632b09809c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -880,7 +880,7 @@ const translations = { canceled: 'Canceled', posted: 'Posted', deleteReceipt: 'Delete receipt', - deletedTransaction: ({amount, merchant}: DeleteTransactionParams) => `deleted an expense on this report, ${amount} - ${merchant}`, + deletedTransaction: ({amount, merchant}: DeleteTransactionParams) => `deleted an expense on this report, ${merchant} - ${amount}`, pendingMatchWithCreditCard: 'Receipt pending match with card transaction', pendingMatchWithCreditCardDescription: 'Receipt pending match with card transaction. Mark as cash to cancel.', markAsCash: 'Mark as cash', diff --git a/src/languages/es.ts b/src/languages/es.ts index 92e94446aa48..6c9ef384f9e7 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -58,6 +58,7 @@ import type { DelegatorParams, DeleteActionParams, DeleteConfirmationParams, + DeleteTransactionParams, DidSplitAmountMessageParams, EditActionParams, EditDestinationSubtitleParams, @@ -878,6 +879,7 @@ const translations = { pendingMatchWithCreditCardDescription: 'Recibo pendiente de adjuntar con la transacción de la tarjeta. Márcalo como efectivo para cancelar.', markAsCash: 'Marcar como efectivo', routePending: 'Ruta pendiente...', + deletedTransaction: ({amount, merchant}: DeleteTransactionParams) => `eliminó un gasto de este informe, ${merchant} - ${amount}`, receiptIssuesFound: () => ({ one: 'Problema encontrado', other: 'Problemas encontrados', diff --git a/src/languages/params.ts b/src/languages/params.ts index ce51a9a7fa06..7d484d4d33a7 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -116,7 +116,7 @@ type RequestCountParams = { }; type DeleteTransactionParams = { - amount: number; + amount: string; merchant: string; }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 81ad094322d5..9364b75d6fa4 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4962,8 +4962,12 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) { function getDeletedTransactionMessage(action: ReportAction) { const deletedTransactionOriginalMessage = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - - const message = Localize.translateLocal('iou.deletedTransaction', {amount: deletedTransactionOriginalMessage.amount ?? 0, merchant: deletedTransactionOriginalMessage.merchant ?? ''}); + const amount = Math.abs(deletedTransactionOriginalMessage.amount ?? 0); + const currency = CurrencyUtils.getCurrencySymbol(deletedTransactionOriginalMessage.currency ?? ''); + const message = Localize.translateLocal('iou.deletedTransaction', { + amount: `${currency}${amount}`, + merchant: deletedTransactionOriginalMessage.merchant ?? '', + }); return message; } diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index bc86c6bc1b0b..5d65ec3850ff 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -377,6 +377,9 @@ type OriginalMessageDeletedTransaction = { /** The amount of the transaction */ amount?: number; + + /** The currency of the transaction */ + currency?: string; }; /** Model of `reimbursement queued` report action */ From 8f4eb989115ffb44712f40b7fe68e9ec3256490e Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 9 Jan 2025 23:35:17 +0700 Subject: [PATCH 3/7] fix lint --- .../home/report/ContextMenu/ContextMenuActions.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 8185461df976..1b55285eb916 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -193,11 +193,11 @@ const ContextMenuActions: ContextMenuAction[] = [ // is false, so we need to pass true here to override this condition. ReportActionComposeFocusManager.focus(true); }); - Report.navigateToAndOpenChildReport(reportAction?.childReportID ?? '-1', reportAction, originalReportID); + Report.navigateToAndOpenChildReport(reportAction?.childReportID, reportAction, originalReportID); }); return; } - Report.navigateToAndOpenChildReport(reportAction?.childReportID ?? '-1', reportAction, originalReportID); + Report.navigateToAndOpenChildReport(reportAction?.childReportID, reportAction, originalReportID); }, getDescription: () => {}, }, @@ -208,7 +208,7 @@ const ContextMenuActions: ContextMenuAction[] = [ successIcon: Expensicons.Checkmark, shouldShow: ({type, isUnreadChat}) => type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION || (type === CONST.CONTEXT_MENU_TYPES.REPORT && !isUnreadChat), onPress: (closePopover, {reportAction, reportID}) => { - const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction) ?? '-1'; + const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction); Report.markCommentAsUnread(originalReportID, reportAction?.created); if (closePopover) { hideContextMenu(true, ReportActionComposeFocusManager.focus); @@ -239,7 +239,7 @@ const ContextMenuActions: ContextMenuAction[] = [ onPress: (closePopover, {reportID, reportAction, draftMessage}) => { if (ReportActionsUtils.isMoneyRequestAction(reportAction)) { hideContextMenu(false); - const childReportID = reportAction?.childReportID ?? '-1'; + const childReportID = `${reportAction?.childReportID ?? CONST.DEFAULT_NUMBER_ID}`; Report.openReport(childReportID); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID)); return; @@ -324,13 +324,13 @@ const ContextMenuActions: ContextMenuAction[] = [ if (closePopover) { hideContextMenu(false, () => { ReportActionComposeFocusManager.focus(); - Report.toggleSubscribeToChildReport(reportAction?.childReportID ?? '-1', reportAction, originalReportID, childReportNotificationPreference); + Report.toggleSubscribeToChildReport(reportAction?.childReportID, reportAction, originalReportID, childReportNotificationPreference); }); return; } ReportActionComposeFocusManager.focus(); - Report.toggleSubscribeToChildReport(reportAction?.childReportID ?? '-1', reportAction, originalReportID, childReportNotificationPreference); + Report.toggleSubscribeToChildReport(reportAction?.childReportID, reportAction, originalReportID, childReportNotificationPreference); }, getDescription: () => {}, }, From c2b3d3f6ed7d00dad3bf24da248fc20c782e6a6d Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 9 Jan 2025 23:41:43 +0700 Subject: [PATCH 4/7] fix lint --- src/libs/actions/Report.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 1e157b983483..559bcb0a6dec 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1363,8 +1363,8 @@ function readNewestAction(reportID: string | undefined, shouldResetUnreadMarker /** * Sets the last read time on a report */ -function markCommentAsUnread(reportID: string, reportActionCreated: string) { - if (reportID === '-1') { +function markCommentAsUnread(reportID?: string, reportActionCreated?: string) { + if (reportID === '-1' || !reportID || !reportActionCreated) { Log.warn('7339cd6c-3263-4f89-98e5-730f0be15784 Invalid report passed to MarkCommentAsUnread. Not calling the API because it wil fail.'); return; } From 180b307e014b44976be871d40cc60b22c98dc6a5 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 13 Jan 2025 13:51:50 +0700 Subject: [PATCH 5/7] fix amount in get message --- 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 ba1cf99e97a5..78807544cf11 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4962,7 +4962,7 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) { function getDeletedTransactionMessage(action: ReportAction) { const deletedTransactionOriginalMessage = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - const amount = Math.abs(deletedTransactionOriginalMessage.amount ?? 0); + const amount = Math.abs(deletedTransactionOriginalMessage.amount ?? 0) / 100; const currency = CurrencyUtils.getCurrencySymbol(deletedTransactionOriginalMessage.currency ?? ''); const message = Localize.translateLocal('iou.deletedTransaction', { amount: `${currency}${amount}`, From a63b6b5f650a7648c202b337abc09db5e317e7f2 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 20 Jan 2025 16:18:06 +0700 Subject: [PATCH 6/7] remmove useless code --- src/CONST.ts | 1 - src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index a175b69829b8..a7f1581cd22c 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1074,7 +1074,6 @@ const CONST = { ADD_CUSTOM_UNIT: 'POLICYCHANGELOG_ADD_CUSTOM_UNIT', ADD_CUSTOM_UNIT_RATE: 'POLICYCHANGELOG_ADD_CUSTOM_UNIT_RATE', ADD_EMPLOYEE: 'POLICYCHANGELOG_ADD_EMPLOYEE', - DELETED_TRANSACTION: 'POLICYCHANGELOG_DELETED_TRANSACTION', ADD_INTEGRATION: 'POLICYCHANGELOG_ADD_INTEGRATION', ADD_REPORT_FIELD: 'POLICYCHANGELOG_ADD_REPORT_FIELD', ADD_TAG: 'POLICYCHANGELOG_ADD_TAG', diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index e76f92fe5aa5..97d54ae7fdcc 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -546,7 +546,7 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(getPolicyChangeLogChangeRoleMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(getPolicyChangeLogDeleteMemberMessage(reportAction)); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETED_TRANSACTION) { + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) { setClipboardMessage(getDeletedTransactionMessage(reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { const {label, errorMessage} = getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''}; From 1afc4577a1b16b9fbb61418d92e7d5c374cd5655 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 20 Jan 2025 16:26:38 +0700 Subject: [PATCH 7/7] fix lint --- .../home/report/PureReportActionItem.tsx | 326 ++++++++++-------- 1 file changed, 179 insertions(+), 147 deletions(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 9319abbf7d59..e2c73ffe6e74 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -11,7 +11,7 @@ import DisplayNames from '@components/DisplayNames'; import Hoverable from '@components/Hoverable'; import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext'; import Icon from '@components/Icon'; -import * as Expensicons from '@components/Icon/Expensicons'; +import {Eye} from '@components/Icon/Expensicons'; import InlineSystemMessage from '@components/InlineSystemMessage'; import KYCWall from '@components/KYCWall'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -38,28 +38,85 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import {openPersonalBankAccountSetupView} from '@libs/actions/BankAccounts'; +import {hideEmojiPicker, isActive} from '@libs/actions/EmojiPickerAction'; +import {acceptJoinRequest, declineJoinRequest} from '@libs/actions/Policy/Member'; +import {expandURLPreview} from '@libs/actions/Report'; +import {isAnonymousUser, signOutAndRedirectToSignIn} from '@libs/actions/Session'; +import {isBlockedFromConcierge} from '@libs/actions/User'; import ControlSelection from '@libs/ControlSelection'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as ErrorUtils from '@libs/ErrorUtils'; +import {canUseTouchScreen} from '@libs/DeviceCapabilities'; +import {getLatestErrorMessageField} from '@libs/ErrorUtils'; +import type {OnyxDataWithErrors} from '@libs/ErrorUtils'; import focusComposerWithDelay from '@libs/focusComposerWithDelay'; -import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Navigation from '@libs/Navigation/Navigation'; import Permissions from '@libs/Permissions'; -import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import * as PolicyUtils from '@libs/PolicyUtils'; -import * as ReportActionsUtils from '@libs/ReportActionsUtils'; -import * as ReportUtils from '@libs/ReportUtils'; +import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; +import {getCleanedTagName} from '@libs/PolicyUtils'; +import { + extractLinksFromMessageHtml, + getDismissedViolationMessageText, + getIOUReportIDFromReportActionPreview, + getOriginalMessage, + getPolicyChangeLogAddEmployeeMessage, + getPolicyChangeLogChangeRoleMessage, + getPolicyChangeLogDeleteMemberMessage, + getRemovedConnectionMessage, + getRemovedFromApprovalChainMessage, + getRenamedAction, + getReportActionMessage, + getReportActionText, + getWhisperedTo, + isActionableAddPaymentCard, + isActionableJoinRequest, + isActionableMentionWhisper, + isActionableReportMentionWhisper, + isActionableTrackExpense, + isActionOfType, + isAddCommentAction, + isChronosOOOListAction, + isCreatedTaskReportAction, + isDeletedAction, + isDeletedParentAction as isDeletedParentActionReportActionUtils, + isMessageDeleted, + isMoneyRequestAction, + isPendingRemove, + isReimbursementDeQueuedAction, + isReimbursementQueuedAction, + isRenamedAction, + isTagModificationAction, + isTaskAction, + isTripPreview, + isUnapprovedAction, + isWhisperActionTargetedToOthers, +} from '@libs/ReportActionsUtils'; +import { + canWriteInReport, + chatIncludesConcierge, + getDeletedTransactionMessage, + getDisplayNamesWithTooltips, + getIconsForParticipants, + getIOUApprovedMessage, + getIOUForwardedMessage, + getIOUSubmittedMessage, + getIOUUnapprovedMessage, + getReportAutomaticallyApprovedMessage, + getReportAutomaticallySubmittedMessage, + getWhisperDisplayNames, + getWorkspaceNameUpdatedMessage, + isArchivedNonExpenseReport, + isChatThread, + isCompletedTaskReport, + isReportMessageAttachment, + isTaskReport, + shouldDisplayThreadReplies as shouldDisplayThreadRepliesReportUtils, +} from '@libs/ReportUtils'; import type {MissingPaymentMethod} from '@libs/ReportUtils'; import SelectionScraper from '@libs/SelectionScraper'; import shouldRenderAddPaymentCard from '@libs/shouldRenderAppPaymentCard'; import {ReactionListContext} from '@pages/home/ReportScreenContext'; -import * as BankAccounts from '@userActions/BankAccounts'; -import * as EmojiPickerAction from '@userActions/EmojiPickerAction'; -import * as Member from '@userActions/Policy/Member'; -import * as Report from '@userActions/Report'; import type {IgnoreDirection} from '@userActions/ReportActions'; -import * as Session from '@userActions/Session'; -import * as User from '@userActions/User'; import CONST from '@src/CONST'; import type {IOUAction} from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -69,8 +126,8 @@ import type {JoinWorkspaceResolution} from '@src/types/onyx/OriginalMessage'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import {RestrictedReadOnlyContextMenuActions} from './ContextMenu/ContextMenuActions'; import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu'; -import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu'; -import {hideContextMenu} from './ContextMenu/ReportActionContextMenu'; +import type {ContextMenuAnchor} from './ContextMenu/ReportActionContextMenu'; +import {hideContextMenu, hideDeleteModal, isActiveReportAction, showContextMenu} from './ContextMenu/ReportActionContextMenu'; import LinkPreviewer from './LinkPreviewer'; import ReportActionItemBasicMessage from './ReportActionItemBasicMessage'; import ReportActionItemContentCreated from './ReportActionItemContentCreated'; @@ -300,7 +357,7 @@ function PureReportActionItem({ const theme = useTheme(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const [isContextMenuActive, setIsContextMenuActive] = useState(() => ReportActionContextMenu.isActiveReportAction(action.reportActionID)); + const [isContextMenuActive, setIsContextMenuActive] = useState(() => isActiveReportAction(action.reportActionID)); const [isEmojiPickerActive, setIsEmojiPickerActive] = useState(); const [isPaymentMethodPopoverActive, setIsPaymentMethodPopoverActive] = useState(); @@ -309,36 +366,32 @@ function PureReportActionItem({ const reactionListRef = useContext(ReactionListContext); const {updateHiddenAttachments} = useContext(ReportAttachmentsContext); const textInputRef = useRef(null); - const popoverAnchorRef = useRef>(null); + const popoverAnchorRef = useRef>(null); const downloadedPreviews = useRef([]); const prevDraftMessage = usePrevious(draftMessage); const isReportActionLinked = linkedReportActionID && action.reportActionID && linkedReportActionID === action.reportActionID; const reportScrollManager = useReportScrollManager(); - const isActionableWhisper = - ReportActionsUtils.isActionableMentionWhisper(action) || ReportActionsUtils.isActionableTrackExpense(action) || ReportActionsUtils.isActionableReportMentionWhisper(action); - const originalMessage = ReportActionsUtils.getOriginalMessage(action); + const isActionableWhisper = isActionableMentionWhisper(action) || isActionableTrackExpense(action) || isActionableReportMentionWhisper(action); + const originalMessage = getOriginalMessage(action); const highlightedBackgroundColorIfNeeded = useMemo( () => (isReportActionLinked ? StyleUtils.getBackgroundColorStyle(theme.messageHighlightBG) : {}), [StyleUtils, isReportActionLinked, theme.messageHighlightBG], ); - const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); + const isDeletedParentAction = isDeletedParentActionReportActionUtils(action); const isOriginalMessageAnObject = originalMessage && typeof originalMessage === 'object'; const hasResolutionInOriginalMessage = isOriginalMessageAnObject && 'resolution' in originalMessage; const prevActionResolution = usePrevious(isActionableWhisper && hasResolutionInOriginalMessage ? originalMessage?.resolution : null); // IOUDetails only exists when we are sending money - const isSendingMoney = - ReportActionsUtils.isMoneyRequestAction(action) && - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && - ReportActionsUtils.getOriginalMessage(action)?.IOUDetails; + const isSendingMoney = isMoneyRequestAction(action) && getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && getOriginalMessage(action)?.IOUDetails; const updateHiddenState = useCallback( (isHiddenValue: boolean) => { setIsHidden(isHiddenValue); const message = Array.isArray(action.message) ? action.message?.at(-1) : action.message; - const isAttachment = ReportUtils.isReportMessageAttachment(message); + const isAttachment = isReportMessageAttachment(message); if (!isAttachment) { return; } @@ -351,12 +404,12 @@ function PureReportActionItem({ () => () => { // ReportActionContextMenu, EmojiPicker and PopoverReactionList are global components, // we should also hide them when the current component is destroyed - if (ReportActionContextMenu.isActiveReportAction(action.reportActionID)) { - ReportActionContextMenu.hideContextMenu(); - ReportActionContextMenu.hideDeleteModal(); + if (isActiveReportAction(action.reportActionID)) { + hideContextMenu(); + hideDeleteModal(); } - if (EmojiPickerAction.isActive(action.reportActionID)) { - EmojiPickerAction.hideEmojiPicker(true); + if (isActive(action.reportActionID)) { + hideEmojiPicker(true); } if (reactionListRef?.current?.isActiveReportAction(action.reportActionID)) { reactionListRef?.current?.hideReactionList(); @@ -367,11 +420,11 @@ function PureReportActionItem({ useEffect(() => { // We need to hide EmojiPicker when this is a deleted parent action - if (!isDeletedParentAction || !EmojiPickerAction.isActive(action.reportActionID)) { + if (!isDeletedParentAction || !isActive(action.reportActionID)) { return; } - EmojiPickerAction.hideEmojiPicker(true); + hideEmojiPicker(true); }, [isDeletedParentAction, action.reportActionID]); useEffect(() => { @@ -387,17 +440,17 @@ function PureReportActionItem({ return; } - const urls = ReportActionsUtils.extractLinksFromMessageHtml(action); + const urls = extractLinksFromMessageHtml(action); if (lodashIsEqual(downloadedPreviews.current, urls) || action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { return; } downloadedPreviews.current = urls; - Report.expandURLPreview(reportID, action.reportActionID); + expandURLPreview(reportID, action.reportActionID); }, [action, reportID]); useEffect(() => { - if (draftMessage === undefined || !ReportActionsUtils.isDeletedAction(action)) { + if (draftMessage === undefined || !isDeletedAction(action)) { return; } deleteReportActionDraft(reportID, action); @@ -405,7 +458,7 @@ function PureReportActionItem({ // Hide the message if it is being moderated for a higher offense, or is hidden by a moderator // Removed messages should not be shown anyway and should not need this flow - const latestDecision = ReportActionsUtils.getReportActionMessage(action)?.moderationDecision?.decision ?? ''; + const latestDecision = getReportActionMessage(action)?.moderationDecision?.decision ?? ''; useEffect(() => { if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT) { return; @@ -419,10 +472,7 @@ function PureReportActionItem({ } setModerationDecision(latestDecision); - if ( - ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && - !ReportActionsUtils.isPendingRemove(action) - ) { + if (![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && !isPendingRemove(action)) { setIsHidden(true); return; } @@ -430,10 +480,10 @@ function PureReportActionItem({ }, [latestDecision, action]); const toggleContextMenuFromActiveReportAction = useCallback(() => { - setIsContextMenuActive(ReportActionContextMenu.isActiveReportAction(action.reportActionID)); + setIsContextMenuActive(isActiveReportAction(action.reportActionID)); }, [action.reportActionID]); - const disabledActions = useMemo(() => (!ReportUtils.canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]); + const disabledActions = useMemo(() => (!canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]); /** * Show the ReportActionContextMenu modal popover. @@ -449,7 +499,7 @@ function PureReportActionItem({ setIsContextMenuActive(true); const selection = SelectionScraper.getCurrentSelection(); - ReportActionContextMenu.showContextMenu( + showContextMenu( CONST.CONTEXT_MENU_TYPES.REPORT_ACTION, event, selection, @@ -522,7 +572,7 @@ function PureReportActionItem({ const mentionReportContextValue = useMemo(() => ({currentReportID: report?.reportID ?? '-1'}), [report?.reportID]); const actionableItemButtons: ActionableItem[] = useMemo(() => { - if (ReportActionsUtils.isActionableAddPaymentCard(action) && userBillingFundID === undefined && shouldRenderAddPaymentCard()) { + if (isActionableAddPaymentCard(action) && userBillingFundID === undefined && shouldRenderAddPaymentCard()) { return [ { text: 'subscription.cardSection.addCardButton', @@ -536,12 +586,12 @@ function PureReportActionItem({ ]; } - if (!isActionableWhisper && (!ReportActionsUtils.isActionableJoinRequest(action) || ReportActionsUtils.getOriginalMessage(action)?.choice !== ('' as JoinWorkspaceResolution))) { + if (!isActionableWhisper && (!isActionableJoinRequest(action) || getOriginalMessage(action)?.choice !== ('' as JoinWorkspaceResolution))) { return []; } - if (ReportActionsUtils.isActionableTrackExpense(action)) { - const transactionID = ReportActionsUtils.getOriginalMessage(action)?.transactionID; + if (isActionableTrackExpense(action)) { + const transactionID = getOriginalMessage(action)?.transactionID; return [ { text: 'actionableMentionTrackExpense.submit', @@ -578,23 +628,23 @@ function PureReportActionItem({ ]; } - if (ReportActionsUtils.isActionableJoinRequest(action)) { + if (isActionableJoinRequest(action)) { return [ { text: 'actionableMentionJoinWorkspaceOptions.accept', key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT}`, - onPress: () => Member.acceptJoinRequest(reportID, action), + onPress: () => acceptJoinRequest(reportID, action), isPrimary: true, }, { text: 'actionableMentionJoinWorkspaceOptions.decline', key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE}`, - onPress: () => Member.declineJoinRequest(reportID, action), + onPress: () => declineJoinRequest(reportID, action), }, ]; } - if (ReportActionsUtils.isActionableReportMentionWhisper(action)) { + if (isActionableReportMentionWhisper(action)) { return [ { text: 'common.yes', @@ -646,19 +696,19 @@ function PureReportActionItem({ // Show the MoneyRequestPreview for when expense is present if ( - ReportActionsUtils.isMoneyRequestAction(action) && - ReportActionsUtils.getOriginalMessage(action) && + isMoneyRequestAction(action) && + getOriginalMessage(action) && // For the pay flow, we only want to show MoneyRequestAction when sending money. When paying, we display a regular system message - (ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE || - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT || - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) + (getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE || + getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT || + getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) ) { // There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID - const iouReportID = ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ? ReportActionsUtils.getOriginalMessage(action)?.IOUReportID?.toString() ?? '-1' : '-1'; + const iouReportID = getOriginalMessage(action)?.IOUReportID ? getOriginalMessage(action)?.IOUReportID?.toString() ?? '-1' : '-1'; children = ( ); - } else if (ReportActionsUtils.isTripPreview(action)) { + } else if (isTripPreview(action)) { children = ( ); - } else if (ReportActionsUtils.isTaskAction(action)) { + } else if (isTaskAction(action)) { children = ; - } else if (ReportActionsUtils.isCreatedTaskReportAction(action)) { + } else if (isCreatedTaskReportAction(action)) { children = ( ); - } else if (ReportActionsUtils.isReimbursementQueuedAction(action)) { - const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; - const submitterDisplayName = LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[linkedReport?.ownerAccountID ?? -1])); - const paymentType = ReportActionsUtils.getOriginalMessage(action)?.paymentType ?? ''; + } else if (isReimbursementQueuedAction(action)) { + const linkedReport = isChatThread(report) ? parentReport : report; + const submitterDisplayName = formatPhoneNumber(getDisplayNameOrDefault(personalDetails?.[linkedReport?.ownerAccountID ?? -1])); + const paymentType = getOriginalMessage(action)?.paymentType ?? ''; children = ( - BankAccounts.openPersonalBankAccountSetupView(Navigation.getTopmostReportId() ?? linkedReport?.reportID, undefined, undefined, isUserValidated) - } + onPress={() => openPersonalBankAccountSetupView(Navigation.getTopmostReportId() ?? linkedReport?.reportID, undefined, undefined, isUserValidated)} pressOnEnter large /> @@ -764,39 +812,36 @@ function PureReportActionItem({ ); - } else if (ReportActionsUtils.isReimbursementDeQueuedAction(action)) { + } else if (isReimbursementDeQueuedAction(action)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) { children = ; - } else if ( - ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || - ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED) - ) { - const wasSubmittedViaHarvesting = ReportActionsUtils.getOriginalMessage(action)?.harvesting ?? false; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED)) { + const wasSubmittedViaHarvesting = getOriginalMessage(action)?.harvesting ?? false; if (wasSubmittedViaHarvesting) { children = ( - ${ReportUtils.getReportAutomaticallySubmittedMessage(action)}`} /> + ${getReportAutomaticallySubmittedMessage(action)}`} /> ); } else { - children = ; + children = ; } - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.APPROVED)) { - const wasAutoApproved = ReportActionsUtils.getOriginalMessage(action)?.automaticAction ?? false; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.APPROVED)) { + const wasAutoApproved = getOriginalMessage(action)?.automaticAction ?? false; if (wasAutoApproved) { children = ( - ${ReportUtils.getReportAutomaticallyApprovedMessage(action)}`} /> + ${getReportAutomaticallyApprovedMessage(action)}`} /> ); } else { - children = ; + children = ; } - } else if (ReportActionsUtils.isUnapprovedAction(action)) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) { - const wasAutoForwarded = ReportActionsUtils.getOriginalMessage(action)?.automaticAction ?? false; + } else if (isUnapprovedAction(action)) { + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) { + const wasAutoForwarded = getOriginalMessage(action)?.automaticAction ?? false; if (wasAutoForwarded) { children = ( @@ -804,7 +849,7 @@ function PureReportActionItem({ ); } else { - children = ; + children = ; } } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { children = ; @@ -815,29 +860,29 @@ function PureReportActionItem({ } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) { children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { - children = ; - } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { - children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { + children = ; + } else if (isTagModificationAction(action.actionName)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { - children = ; + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { + children = ; } else if ( - ReportActionsUtils.isActionOfType( + isActionOfType( action, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL, @@ -851,20 +896,19 @@ function PureReportActionItem({ policyID={report?.policyID} /> ); - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION)) { + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION)) { children = ; - } else if (ReportActionsUtils.isRenamedAction(action)) { - const message = ReportActionsUtils.getRenamedAction(action); + } else if (isRenamedAction(action)) { + const message = getRenamedAction(action); children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { - const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(action) ?? {label: '', errorMessage: ''}; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { + const {label, errorMessage} = getOriginalMessage(action) ?? {label: '', errorMessage: ''}; children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { - children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { + children = ; } else { const hasBeenFlagged = - ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && - !ReportActionsUtils.isPendingRemove(action); + ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && !isPendingRemove(action); children = ( @@ -899,7 +943,7 @@ function PureReportActionItem({ {actionableItemButtons.length > 0 && ( )} @@ -912,8 +956,7 @@ function PureReportActionItem({ index={index} ref={textInputRef} shouldDisableEmojiPicker={ - (ReportUtils.chatIncludesConcierge(report) && User.isBlockedFromConcierge(blockedFromConcierge)) || - ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) + (chatIncludesConcierge(report) && isBlockedFromConcierge(blockedFromConcierge)) || isArchivedNonExpenseReport(report, reportNameValuePairs) } isGroupPolicyReport={!!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE} /> @@ -925,7 +968,7 @@ function PureReportActionItem({ } const numberOfThreadReplies = action.childVisibleActionCount ?? 0; - const shouldDisplayThreadReplies = ReportUtils.shouldDisplayThreadReplies(action, isThreadReportParentAction); + const shouldDisplayThreadReplies = shouldDisplayThreadRepliesReportUtils(action, isThreadReportParentAction); const oldestFourAccountIDs = action.childOldestFourAccountIDs ?.split(',') @@ -941,18 +984,18 @@ function PureReportActionItem({ !isEmptyObject(item))} /> )} - {!ReportActionsUtils.isMessageDeleted(action) && ( + {!isMessageDeleted(action) && ( { - if (Session.isAnonymousUser()) { + if (isAnonymousUser()) { hideContextMenu(false); InteractionManager.runAfterInteractions(() => { - Session.signOutAndRedirectToSignIn(); + signOutAndRedirectToSignIn(); }); } else { toggleReaction(emoji, ignoreSkinToneOnCompare); @@ -970,7 +1013,7 @@ function PureReportActionItem({ numberOfReplies={numberOfThreadReplies} mostRecentReply={`${action.childLastVisibleActionCreated}`} isHovered={hovered} - icons={ReportUtils.getIconsForParticipants(oldestFourAccountIDs, personalDetails)} + icons={getIconsForParticipants(oldestFourAccountIDs, personalDetails)} onSecondaryInteraction={showPopover} /> @@ -1005,8 +1048,7 @@ function PureReportActionItem({ iouReport={iouReport} isHovered={hovered} hasBeenFlagged={ - ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && - !ReportActionsUtils.isPendingRemove(action) + ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && !isPendingRemove(action) } > {content} @@ -1018,9 +1060,7 @@ function PureReportActionItem({ }; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { - const transactionID = ReportActionsUtils.isMoneyRequestAction(parentReportActionForTransactionThread) - ? ReportActionsUtils.getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID - : '-1'; + const transactionID = isMoneyRequestAction(parentReportActionForTransactionThread) ? getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID : '-1'; return ( ); } - if (ReportActionsUtils.isChronosOOOListAction(action)) { + if (isChronosOOOListAction(action)) { return ( 1; - const iouReportID = - ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUReportID - ? (ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ?? '').toString() - : '-1'; + const iouReportID = isMoneyRequestAction(action) && getOriginalMessage(action)?.IOUReportID ? (getOriginalMessage(action)?.IOUReportID ?? '').toString() : '-1'; const transactionsWithReceipts = getTransactionsWithReceipts(iouReportID); const isWhisper = whisperedTo.length > 0 && transactionsWithReceipts.length === 0; const whisperedToPersonalDetails = isWhisper ? (Object.values(personalDetails ?? {}).filter((details) => whisperedTo.includes(details?.accountID ?? -1)) as OnyxTypes.PersonalDetails[]) : []; const isWhisperOnlyVisibleByUser = isWhisper && isCurrentUserTheOnlyParticipant(whisperedTo); - const displayNamesWithTooltips = isWhisper ? ReportUtils.getDisplayNamesWithTooltips(whisperedToPersonalDetails, isMultipleParticipant) : []; + const displayNamesWithTooltips = isWhisper ? getDisplayNamesWithTooltips(whisperedToPersonalDetails, isMultipleParticipant) : []; return ( shouldUseNarrowLayout && DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} + onPressIn={() => shouldUseNarrowLayout && canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} onSecondaryInteraction={showPopover} preventDefaultContextMenu={draftMessage === undefined && !hasErrors} @@ -1134,7 +1166,7 @@ function PureReportActionItem({ > { - const transactionID = ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID : undefined; + const transactionID = isMoneyRequestAction(action) ? getOriginalMessage(action)?.IOUTransactionID : undefined; if (transactionID) { clearError(transactionID); } @@ -1145,9 +1177,9 @@ function PureReportActionItem({ draftMessage !== undefined ? undefined : action.pendingAction ?? (action.isOptimisticAction ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : undefined) } shouldHideOnDelete={!isThreadReportParentAction} - errors={linkedTransactionRouteError ?? ErrorUtils.getLatestErrorMessageField(action as ErrorUtils.OnyxDataWithErrors)} + errors={linkedTransactionRouteError ?? getLatestErrorMessageField(action as OnyxDataWithErrors)} errorRowStyles={[styles.ml10, styles.mr2]} - needsOffscreenAlphaCompositing={ReportActionsUtils.isMoneyRequestAction(action)} + needsOffscreenAlphaCompositing={isMoneyRequestAction(action)} shouldDisableStrikeThrough > {isWhisper && ( @@ -1155,7 +1187,7 @@ function PureReportActionItem({ @@ -1164,7 +1196,7 @@ function PureReportActionItem({   { prevProps.report?.parentReportID === nextProps.report?.parentReportID && prevProps.report?.parentReportActionID === nextProps.report?.parentReportActionID && // TaskReport's created actions render the TaskView, which updates depending on certain fields in the TaskReport - ReportUtils.isTaskReport(prevProps.report) === ReportUtils.isTaskReport(nextProps.report) && + isTaskReport(prevProps.report) === isTaskReport(nextProps.report) && prevProps.action.actionName === nextProps.action.actionName && prevProps.report?.reportName === nextProps.report?.reportName && prevProps.report?.description === nextProps.report?.description && - ReportUtils.isCompletedTaskReport(prevProps.report) === ReportUtils.isCompletedTaskReport(nextProps.report) && + isCompletedTaskReport(prevProps.report) === isCompletedTaskReport(nextProps.report) && prevProps.report?.managerID === nextProps.report?.managerID && prevProps.shouldHideThreadDividerLine === nextProps.shouldHideThreadDividerLine && prevProps.report?.total === nextProps.report?.total &&