From 06f8a142e44dd71bf1e6c385499c363586e3b3a7 Mon Sep 17 00:00:00 2001 From: gijoe0295 Date: Thu, 25 Jul 2024 15:53:32 +0700 Subject: [PATCH 1/3] build MODIFIED_EXPENSE message for reimbursable --- src/libs/ModifiedExpenseMessage.ts | 13 +++++++++++++ src/types/onyx/OriginalMessage.ts | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 38562edb7704..6e9ba2cfe0dc 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -261,6 +261,19 @@ function getForReportAction(reportID: string | undefined, reportAction: OnyxEntr ); } + const hasModifiedReimbursable = reportActionOriginalMessage && 'oldReimbursable' in reportActionOriginalMessage && 'reimbursable' in reportActionOriginalMessage; + if (hasModifiedReimbursable) { + buildMessageFragmentForValue( + String(reportActionOriginalMessage?.reimbursable) ?? '', + String(reportActionOriginalMessage?.oldReimbursable) ?? '', + Localize.translateLocal('iou.expense'), + true, + setFragments, + removalFragments, + changeFragments, + ); + } + const message = getMessageLine(`\n${Localize.translateLocal('iou.changed')}`, changeFragments) + getMessageLine(`\n${Localize.translateLocal('iou.set')}`, setFragments) + diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 06b31f242989..8a9f270f4e25 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -317,6 +317,12 @@ type OriginalMessageModifiedExpense = { /** Old expense tax rate */ oldTaxRate?: string; + /** Edited expense reimbursable */ + reimbursable?: boolean; + + /** Old expense reimbursable */ + oldReimbursable?: boolean; + /** Collection of accountIDs of users mentioned in expense report */ whisperedTo?: number[]; From e49a9f4d1c39b4a16f9eddb35795be1db4b04f41 Mon Sep 17 00:00:00 2001 From: gijoe0295 Date: Sat, 27 Jul 2024 01:38:56 +0700 Subject: [PATCH 2/3] update copy --- src/languages/en.ts | 2 ++ src/languages/es.ts | 2 ++ src/libs/ModifiedExpenseMessage.ts | 11 +++++++++-- src/types/onyx/OriginalMessage.ts | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index b37ad15004e4..c98bdef35ac9 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -833,6 +833,8 @@ export default { headsUp: 'Heads up!', unapproveWithIntegrationWarning: (accountingIntegration: string) => `This report has already been exported to ${accountingIntegration}. Changes to this report in Expensify may lead to data discrepancies and Expensify Card reconciliation issues. Are you sure you want to unapprove this report?`, + reimbursable: 'reimbursable', + nonReimbursable: 'non-reimbursable', }, notificationPreferencesPage: { header: 'Notification preferences', diff --git a/src/languages/es.ts b/src/languages/es.ts index 54c97e41afb1..df299375f7a8 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -839,6 +839,8 @@ export default { headsUp: 'Atención!', unapproveWithIntegrationWarning: (accountingIntegration: string) => `Este informe ya se ha exportado a ${accountingIntegration}. Los cambios realizados en este informe en Expensify pueden provocar discrepancias en los datos y problemas de conciliación de la tarjeta Expensify. ¿Está seguro de que desea anular la aprobación de este informe?`, + reimbursable: 'reembolsable', + nonReimbursable: 'no reembolsable', }, notificationPreferencesPage: { header: 'Preferencias de avisos', diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 6e9ba2cfe0dc..d2a776941a9a 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -24,6 +24,13 @@ Onyx.connect({ }, }); +/** + * Utility to get message based on boolean literal value. + */ +function getBooleanLiteralMessage(value: string | undefined, truthyMessage: string, falsyMessage: string): string { + return value === 'true' ? truthyMessage : falsyMessage; +} + /** * Builds the partial message fragment for a modified field on the expense. */ @@ -264,8 +271,8 @@ function getForReportAction(reportID: string | undefined, reportAction: OnyxEntr const hasModifiedReimbursable = reportActionOriginalMessage && 'oldReimbursable' in reportActionOriginalMessage && 'reimbursable' in reportActionOriginalMessage; if (hasModifiedReimbursable) { buildMessageFragmentForValue( - String(reportActionOriginalMessage?.reimbursable) ?? '', - String(reportActionOriginalMessage?.oldReimbursable) ?? '', + getBooleanLiteralMessage(reportActionOriginalMessage?.reimbursable, Localize.translateLocal('iou.reimbursable'), Localize.translateLocal('iou.nonReimbursable')), + getBooleanLiteralMessage(reportActionOriginalMessage?.oldReimbursable, Localize.translateLocal('iou.reimbursable'), Localize.translateLocal('iou.nonReimbursable')), Localize.translateLocal('iou.expense'), true, setFragments, diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 8a9f270f4e25..6860d606e4f8 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -318,10 +318,10 @@ type OriginalMessageModifiedExpense = { oldTaxRate?: string; /** Edited expense reimbursable */ - reimbursable?: boolean; + reimbursable?: string; /** Old expense reimbursable */ - oldReimbursable?: boolean; + oldReimbursable?: string; /** Collection of accountIDs of users mentioned in expense report */ whisperedTo?: number[]; From b79bf84bc51163b1bbed7dd814f8a9a95bf36b18 Mon Sep 17 00:00:00 2001 From: gijoe0295 Date: Sat, 27 Jul 2024 02:30:58 +0700 Subject: [PATCH 3/3] update copy grammar --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 96b4d7d5078e..334781c998ae 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -756,7 +756,7 @@ export default { `estableció la distancia a ${newDistanceToDisplay}, lo que estableció el importe a ${newAmountToDisplay}`, removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) => `${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} (previamente ${oldValueToDisplay})`, updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) => - `${valueName === 'comerciante' || valueName === 'importe' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`, + `${valueName === 'comerciante' || valueName === 'importe' || valueName === 'gasto' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`, updatedTheDistance: ({newDistanceToDisplay, oldDistanceToDisplay, newAmountToDisplay, oldAmountToDisplay}: UpdatedTheDistanceParams) => `cambió la distancia a ${newDistanceToDisplay} (previamente ${oldDistanceToDisplay}), lo que cambió el importe a ${newAmountToDisplay} (previamente ${oldAmountToDisplay})`, threadExpenseReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${comment ? `${formattedAmount} para ${comment}` : `Gasto de ${formattedAmount}`}`,