From 315cfd44c1134448e1e78dc53aba49f763745118 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Wed, 16 Oct 2024 07:40:20 -0700 Subject: [PATCH] Fix lint / dependency cycle --- src/libs/ReportActionsUtils.ts | 13 +++++-------- src/pages/home/report/ReportActionsList.tsx | 5 ++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 9c9413c54c91..395aa6ebb381 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -2,7 +2,6 @@ import {fastMerge, Str} from 'expensify-common'; import clone from 'lodash/clone'; import lodashFindLast from 'lodash/findLast'; import isEmpty from 'lodash/isEmpty'; -import {report} from 'process'; import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; @@ -29,7 +28,6 @@ import * as PersonalDetailsUtils from './PersonalDetailsUtils'; import * as PolicyUtils from './PolicyUtils'; import * as ReportConnection from './ReportConnection'; import type {OptimisticIOUReportAction, PartialReportAction} from './ReportUtils'; -import * as ReportUtils from './ReportUtils'; import StringUtils from './StringUtils'; // eslint-disable-next-line import/no-cycle import * as TransactionUtils from './TransactionUtils'; @@ -595,20 +593,19 @@ function isConsecutiveActionMadeByPreviousActor(reportActions: ReportAction[] | return currentAction.actorAccountID === previousAction.actorAccountID; } -function isChronosAutomaticTimerAction(reportAction: OnyxInputOrEntry): boolean { - const isChronosReport = ReportUtils.chatIncludesChronosWithID(reportAction?.reportID); - const isAutomaticTimerAction = /start(?:ed|ing)?(?:\snow)?/i.test(getReportActionText(reportAction)); - return isChronosReport && isAutomaticTimerAction; +function isChronosAutomaticTimerAction(reportAction: OnyxInputOrEntry, isChronosReport: boolean): boolean { + const isAutomaticTimerAction = () => /start(?:ed|ing)?(?:\snow)?/i.test(getReportActionText(reportAction)); + return isChronosReport && isAutomaticTimerAction(); } /** * If the user sends consecutive actions to Chronos to start/stop the timer, * then detect that and show each individually so that the user can easily see when they were sent. */ -function isConsecutiveChronosAutomaticTimerAction(reportActions: ReportAction[], actionIndex: number): boolean { +function isConsecutiveChronosAutomaticTimerAction(reportActions: ReportAction[], actionIndex: number, isChronosReport: boolean): boolean { const previousAction = findPreviousAction(reportActions, actionIndex); const currentAction = reportActions?.at(actionIndex); - return isChronosAutomaticTimerAction(currentAction) && isChronosAutomaticTimerAction(previousAction); + return isChronosAutomaticTimerAction(currentAction, isChronosReport) && isChronosAutomaticTimerAction(previousAction, isChronosReport); } /** diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index f5e1dc309d0b..12106f3fb92b 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -512,7 +512,10 @@ function ReportActionsList({ report={report} transactionThreadReport={transactionThreadReport} linkedReportActionID={linkedReportActionID} - displayAsGroup={!ReportActionsUtils.isConsecutiveChronosAutomaticTimerAction && ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedVisibleReportActions, index)} + displayAsGroup={ + !ReportActionsUtils.isConsecutiveChronosAutomaticTimerAction(sortedVisibleReportActions, index, ReportUtils.chatIncludesChronosWithID(reportAction?.reportID)) && + ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedVisibleReportActions, index) + } mostRecentIOUReportActionID={mostRecentIOUReportActionID} shouldHideThreadDividerLine={shouldHideThreadDividerLine} shouldDisplayNewMarker={reportAction.reportActionID === unreadMarkerReportActionID}