From 326f61db384de6570d3a0fe0708acfc878ce1760 Mon Sep 17 00:00:00 2001 From: Weslley Alves Date: Thu, 11 Jan 2024 20:38:07 -0300 Subject: [PATCH] Remove inner method and put its content in the place where is using the removed method --- src/libs/ModifiedExpenseMessage.ts | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index c38a0deaea40..90d37b2328ce 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -87,22 +87,6 @@ function getForDistanceRequest(newDistance: string, oldDistance: string, newAmou }); } -/** - * Build message fragment for the created property when this value was changed - */ -function buildMessageFragmentForCreated(setFragments: string[], removalFragments: string[], changeFragments: string[], reportActionOriginalMessage?: ExpenseOriginalMessage) { - const {created, oldCreated} = reportActionOriginalMessage ?? {}; - - if (!oldCreated || !created) { - return; - } - - // Take only the YYYY-MM-DD value as the original date includes timestamp - const formattedOldCreated = DateUtils.formatWithUTCTimeZone(oldCreated, CONST.DATE.FNS_FORMAT_STRING); - - buildMessageFragmentForValue(created, formattedOldCreated, Localize.translateLocal('common.date'), false, setFragments, removalFragments, changeFragments); -} - /** * Get the report action message when expense has been modified. * @@ -159,7 +143,19 @@ function getForReportAction(reportAction: ReportAction): string { ); } - buildMessageFragmentForCreated(setFragments, removalFragments, changeFragments, reportActionOriginalMessage); + if (reportActionOriginalMessage?.oldCreated && reportActionOriginalMessage?.created) { + const formattedOldCreated = DateUtils.formatWithUTCTimeZone(reportActionOriginalMessage.oldCreated, CONST.DATE.FNS_FORMAT_STRING); + + buildMessageFragmentForValue( + reportActionOriginalMessage.created, + formattedOldCreated, + Localize.translateLocal('common.date'), + false, + setFragments, + removalFragments, + changeFragments, + ); + } if (hasModifiedMerchant) { buildMessageFragmentForValue(