diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 44c7682b47f2..9b96bfa009dc 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -1,6 +1,7 @@ import { addDays, addHours, + addMilliseconds, addMinutes, eachDayOfInterval, eachMonthOfInterval, @@ -392,6 +393,13 @@ function subtractMillisecondsFromDateTime(dateTime: string, milliseconds: number return getDBTime(newTimestamp); } +function addMillisecondsFromDateTime(dateTime: string, milliseconds: number): string { + const date = zonedTimeToUtc(dateTime, 'UTC'); + const newTimestamp = addMilliseconds(date, milliseconds).valueOf(); + + return getDBTime(newTimestamp); +} + /** * @param isoTimestamp example: 2023-05-16 05:34:14.388 * @returns example: 2023-05-16 @@ -784,6 +792,7 @@ const DateUtils = { getDBTimeWithSkew, setLocale, subtractMillisecondsFromDateTime, + addMillisecondsFromDateTime, getDateStringFromISOTimestamp, getThirtyMinutesFromNow, getEndOfToday, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 1b60cd611d57..f5eccb046765 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4042,7 +4042,7 @@ function buildOptimisticHoldReportAction(created = DateUtils.getDBTime()): Optim function buildOptimisticHoldReportActionComment(comment: string, created = DateUtils.getDBTime()): OptimisticHoldReportAction { return { reportActionID: NumberUtils.rand64(), - actionName: CONST.REPORT.ACTIONS.TYPE.HOLDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, actorAccountID: currentUserAccountID, message: [ diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index cd0264ddb6ea..427cc152c056 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5392,8 +5392,9 @@ function setShownHoldUseExplanation() { * Put money request on HOLD */ function putOnHold(transactionID: string, comment: string, reportID: string) { - const createdReportAction = ReportUtils.buildOptimisticHoldReportAction(); - const createdReportActionComment = ReportUtils.buildOptimisticHoldReportActionComment(comment); + const currentTime = DateUtils.getDBTime(); + const createdReportAction = ReportUtils.buildOptimisticHoldReportAction(currentTime); + const createdReportActionComment = ReportUtils.buildOptimisticHoldReportActionComment(comment, DateUtils.addMillisecondsFromDateTime(currentTime, 1)); const optimisticData: OnyxUpdate[] = [ {