Skip to content

Commit cc7ac35

Browse files
authored
Merge pull request #50679 from Expensify/neil-chronos-offline
Display Chronos offline time tracking nicely
2 parents 4796961 + 30b8866 commit cc7ac35

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/libs/ReportActionsUtils.ts

+17
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,22 @@ function isConsecutiveActionMadeByPreviousActor(reportActions: ReportAction[] |
581581
return currentAction.actorAccountID === previousAction.actorAccountID;
582582
}
583583

584+
function isChronosAutomaticTimerAction(reportAction: OnyxInputOrEntry<ReportAction>, isChronosReport: boolean): boolean {
585+
const isAutomaticStartTimerAction = () => /start(?:ed|ing)?(?:\snow)?/i.test(getReportActionText(reportAction));
586+
const isAutomaticStopTimerAction = () => /stop(?:ped|ping)?(?:\snow)?/i.test(getReportActionText(reportAction));
587+
return isChronosReport && (isAutomaticStartTimerAction() || isAutomaticStopTimerAction());
588+
}
589+
590+
/**
591+
* If the user sends consecutive actions to Chronos to automatically start/stop the timer,
592+
* then detect that and show each individually so that the user can easily see when they were sent.
593+
*/
594+
function isConsecutiveChronosAutomaticTimerAction(reportActions: ReportAction[], actionIndex: number, isChronosReport: boolean): boolean {
595+
const previousAction = findPreviousAction(reportActions, actionIndex);
596+
const currentAction = reportActions?.at(actionIndex);
597+
return isChronosAutomaticTimerAction(currentAction, isChronosReport) && isChronosAutomaticTimerAction(previousAction, isChronosReport);
598+
}
599+
584600
/**
585601
* Checks if a reportAction is deprecated.
586602
*/
@@ -1834,6 +1850,7 @@ export {
18341850
isChronosOOOListAction,
18351851
isClosedAction,
18361852
isConsecutiveActionMadeByPreviousActor,
1853+
isConsecutiveChronosAutomaticTimerAction,
18371854
isCreatedAction,
18381855
isCreatedTaskReportAction,
18391856
isCurrentActionUnread,

src/pages/home/report/ReportActionsList.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,10 @@ function ReportActionsList({
515515
report={report}
516516
transactionThreadReport={transactionThreadReport}
517517
linkedReportActionID={linkedReportActionID}
518-
displayAsGroup={ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedVisibleReportActions, index)}
518+
displayAsGroup={
519+
!ReportActionsUtils.isConsecutiveChronosAutomaticTimerAction(sortedVisibleReportActions, index, ReportUtils.chatIncludesChronosWithID(reportAction?.reportID)) &&
520+
ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedVisibleReportActions, index)
521+
}
519522
mostRecentIOUReportActionID={mostRecentIOUReportActionID}
520523
shouldHideThreadDividerLine={shouldHideThreadDividerLine}
521524
shouldDisplayNewMarker={reportAction.reportActionID === unreadMarkerReportActionID}

0 commit comments

Comments
 (0)