From 30e4bde8256c420c870fab8113292800c47d7a81 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Sat, 1 Feb 2025 08:22:07 +0700 Subject: [PATCH 01/10] fix: moving expense to selfDM message not correct --- src/libs/ModifiedExpenseMessage.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 1d5946dc25b8..a593b2f097c7 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -1,6 +1,7 @@ import isEmpty from 'lodash/isEmpty'; import Onyx from 'react-native-onyx'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; +import {isSelfDM} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PolicyTagLists, Report, ReportAction} from '@src/types/onyx'; @@ -139,11 +140,20 @@ function getForDistanceRequest(newMerchant: string, oldMerchant: string, newAmou function getForExpenseMovedFromSelfDM(destinationReportID: string) { const destinationReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${destinationReportID}`]; const rootParentReport = getRootParentReport(destinationReport); - - // The "Move report" flow only supports moving expenses to a policy expense chat or a 1:1 DM. + // The "Move report" flow only supports moving expenses from selfDM to: + // 1. A policy expense chat + // 2. A 1:1 DM + // However, in the olddot, expenses could be moved back to a self-DM. + // To maintain consistency and handle this case, we provide a fallback message. + if (isSelfDM(rootParentReport)) { + return translateLocal('iou.changedTheExpense'); + } const reportName = isPolicyExpenseChat(rootParentReport) ? getPolicyExpenseChatName(rootParentReport) : buildReportNameFromParticipantNames({report: rootParentReport}); const policyName = getPolicyName(rootParentReport, true); - + // If we can't determine either the report name or policy name, return the default message + if (isEmpty(policyName) && !reportName) { + return translateLocal('iou.changedTheExpense'); + } return translateLocal('iou.movedFromSelfDM', { reportName, workspaceName: !isEmpty(policyName) ? policyName : undefined, From 5f1d3ff8b40fbe563dbe41740d47170277fb2f74 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Sat, 1 Feb 2025 10:28:41 +0700 Subject: [PATCH 02/10] test: implement test for move expense to selfDM --- tests/unit/ModifiedExpenseMessageTest.ts | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index fbf9b121069b..6a3daa5a10f6 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -396,5 +396,50 @@ describe('ModifiedExpenseMessage', () => { expect(result).toEqual(expectedResult); }); }); + + describe('when move report', () => { + it('return the message "changed the expense" when moving an expense from an expense chat or 1:1 DM to selfDM', () => { + // Given the selfDM report and report action + const report = { + ...createRandomReport(1), + chatType: CONST.REPORT.CHAT_TYPE.SELF_DM, + }; + const reportAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, + originalMessage: { + movedToReportID: 1, + }, + }; + + const expectedResult = 'changed the expense'; + // When the expense move from an expense chat or 1:1 DM to selfDM + const result = ModifiedExpenseMessage.getForReportAction(report.reportID, reportAction); + // Then it should return the 'changed the expense' message + expect(result).toEqual(expectedResult); + }); + + it('return the message "changed the expense" when reportName and workspace name are empty', () => { + // Given the report with empty name and report action + const report = { + ...createRandomReport(1), + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + reportName: '', + }; + const reportAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, + originalMessage: { + movedToReportID: 1, + }, + }; + + const expectedResult = 'changed the expense'; + // When the expense move from expense chat with reportName empty + const result = ModifiedExpenseMessage.getForReportAction(report.reportID, reportAction); + // Then it should return the 'changed the expense' message + expect(result).toEqual(expectedResult); + }); + }); }); }); From 54cd42446808a0c4ad5e6b7dbe4dfae96badb252 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Sat, 1 Feb 2025 11:56:28 +0700 Subject: [PATCH 03/10] fix: eslint fail --- src/libs/ModifiedExpenseMessage.ts | 3 +-- tests/unit/ModifiedExpenseMessageTest.ts | 29 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index a593b2f097c7..f88c03eab9ac 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -1,7 +1,6 @@ import isEmpty from 'lodash/isEmpty'; import Onyx from 'react-native-onyx'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; -import {isSelfDM} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PolicyTagLists, Report, ReportAction} from '@src/types/onyx'; @@ -13,7 +12,7 @@ import Log from './Log'; import {getCleanedTagName, getSortedTagKeys} from './PolicyUtils'; import {getOriginalMessage, isModifiedExpenseAction} from './ReportActionsUtils'; // eslint-disable-next-line import/no-cycle -import {buildReportNameFromParticipantNames, getPolicyExpenseChatName, getPolicyName, getRootParentReport, isPolicyExpenseChat} from './ReportUtils'; +import {buildReportNameFromParticipantNames, getPolicyExpenseChatName, getPolicyName, getRootParentReport, isPolicyExpenseChat, isSelfDM} from './ReportUtils'; import {getTagArrayFromName} from './TransactionUtils'; let allPolicyTags: OnyxCollection = {}; diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index 6a3daa5a10f6..d310c3a9b226 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -1,7 +1,10 @@ +import Onyx from 'react-native-onyx'; import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import createRandomReportAction from '../utils/collections/reportActions'; import createRandomReport from '../utils/collections/reports'; +import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; describe('ModifiedExpenseMessage', () => { describe('getForAction', () => { @@ -398,45 +401,51 @@ describe('ModifiedExpenseMessage', () => { }); describe('when move report', () => { - it('return the message "changed the expense" when moving an expense from an expense chat or 1:1 DM to selfDM', () => { + beforeEach(() => Onyx.clear()); + it('return the message "changed the expense" when moving an expense from an expense chat or 1:1 DM to selfDM', async () => { // Given the selfDM report and report action - const report = { - ...createRandomReport(1), + const selfDMReport = { + ...report, chatType: CONST.REPORT.CHAT_TYPE.SELF_DM, }; const reportAction = { ...createRandomReportAction(1), actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { - movedToReportID: 1, + movedToReportID: selfDMReport.reportID, }, }; + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`]: selfDMReport}); + await waitForBatchedUpdates(); const expectedResult = 'changed the expense'; // When the expense move from an expense chat or 1:1 DM to selfDM - const result = ModifiedExpenseMessage.getForReportAction(report.reportID, reportAction); + const result = ModifiedExpenseMessage.getForReportAction(selfDMReport.reportID, reportAction); // Then it should return the 'changed the expense' message expect(result).toEqual(expectedResult); }); - it('return the message "changed the expense" when reportName and workspace name are empty', () => { + it('return the message "changed the expense" when reportName and workspace name are empty', async () => { // Given the report with empty name and report action - const report = { - ...createRandomReport(1), + const emptyReportNameReport = { + ...report, chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, reportName: '', + isOwnPolicyExpenseChat: false, }; const reportAction = { ...createRandomReportAction(1), actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { - movedToReportID: 1, + movedToReportID: emptyReportNameReport.reportID, }, }; + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${emptyReportNameReport.reportID}`]: emptyReportNameReport}); + await waitForBatchedUpdates(); const expectedResult = 'changed the expense'; // When the expense move from expense chat with reportName empty - const result = ModifiedExpenseMessage.getForReportAction(report.reportID, reportAction); + const result = ModifiedExpenseMessage.getForReportAction(emptyReportNameReport.reportID, reportAction); // Then it should return the 'changed the expense' message expect(result).toEqual(expectedResult); }); From cba621d4dbe1970c6e119873fd394b55532e30c2 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Sun, 2 Feb 2025 14:33:42 +0700 Subject: [PATCH 04/10] fix: correct grammar in comment --- tests/unit/ModifiedExpenseMessageTest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index d310c3a9b226..642fbe5ead21 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -400,7 +400,7 @@ describe('ModifiedExpenseMessage', () => { }); }); - describe('when move report', () => { + describe('when moving an expense', () => { beforeEach(() => Onyx.clear()); it('return the message "changed the expense" when moving an expense from an expense chat or 1:1 DM to selfDM', async () => { // Given the selfDM report and report action @@ -419,7 +419,7 @@ describe('ModifiedExpenseMessage', () => { await waitForBatchedUpdates(); const expectedResult = 'changed the expense'; - // When the expense move from an expense chat or 1:1 DM to selfDM + // When the expense is moved from an expense chat or 1:1 DM to selfDM const result = ModifiedExpenseMessage.getForReportAction(selfDMReport.reportID, reportAction); // Then it should return the 'changed the expense' message expect(result).toEqual(expectedResult); @@ -444,7 +444,7 @@ describe('ModifiedExpenseMessage', () => { await waitForBatchedUpdates(); const expectedResult = 'changed the expense'; - // When the expense move from expense chat with reportName empty + // When the expense is moved from an expense chat with reportName empty const result = ModifiedExpenseMessage.getForReportAction(emptyReportNameReport.reportID, reportAction); // Then it should return the 'changed the expense' message expect(result).toEqual(expectedResult); From 7699f8960f2018633307d588ab549b7b04369db9 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Sun, 2 Feb 2025 15:37:47 +0700 Subject: [PATCH 05/10] test: implement test when the expense is moved from an expense chat --- tests/unit/ModifiedExpenseMessageTest.ts | 74 +++++++++++++++++++++--- 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index 642fbe5ead21..58bc6858740a 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -1,6 +1,7 @@ import Onyx from 'react-native-onyx'; import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; import CONST from '@src/CONST'; +import {translate} from '@src/libs/Localize'; import ONYXKEYS from '@src/ONYXKEYS'; import createRandomReportAction from '../utils/collections/reportActions'; import createRandomReport from '../utils/collections/reports'; @@ -418,7 +419,9 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`]: selfDMReport}); await waitForBatchedUpdates(); - const expectedResult = 'changed the expense'; + // Given the correct text message + const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.changedTheExpense'); + // When the expense is moved from an expense chat or 1:1 DM to selfDM const result = ModifiedExpenseMessage.getForReportAction(selfDMReport.reportID, reportAction); // Then it should return the 'changed the expense' message @@ -426,8 +429,8 @@ describe('ModifiedExpenseMessage', () => { }); it('return the message "changed the expense" when reportName and workspace name are empty', async () => { - // Given the report with empty name and report action - const emptyReportNameReport = { + // Given the policyExpenseChat with reportName is empty and report action + const policyExpenseChat = { ...report, chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, reportName: '', @@ -437,18 +440,73 @@ describe('ModifiedExpenseMessage', () => { ...createRandomReportAction(1), actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { - movedToReportID: emptyReportNameReport.reportID, + movedToReportID: policyExpenseChat.reportID, }, }; - await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${emptyReportNameReport.reportID}`]: emptyReportNameReport}); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat}); await waitForBatchedUpdates(); - const expectedResult = 'changed the expense'; - // When the expense is moved from an expense chat with reportName empty - const result = ModifiedExpenseMessage.getForReportAction(emptyReportNameReport.reportID, reportAction); + // Given the correct text message + const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.changedTheExpense'); + + // When the expense is moved to an expense chat with reportName empty + const result = ModifiedExpenseMessage.getForReportAction(policyExpenseChat.reportID, reportAction); // Then it should return the 'changed the expense' message expect(result).toEqual(expectedResult); }); + + it('return the message "moved expense from self DM to ${policyName}" when both reportName and policyName are present', async () => { + // Given the policyExpenseChat with both reportName and policyName are present and report action + const policyExpenseChat = { + ...report, + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + isOwnPolicyExpenseChat: false, + policyName: 'fake policyName', + }; + const reportAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, + originalMessage: { + movedToReportID: policyExpenseChat.reportID, + }, + }; + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat}); + await waitForBatchedUpdates(); + + // Given the correct text message + const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromSelfDM', {reportName: policyExpenseChat.reportName, workspaceName: policyExpenseChat.policyName}); + + // When the expense is moved to an expense chat with both reportName and policyName are present + const result = ModifiedExpenseMessage.getForReportAction(policyExpenseChat.reportID, reportAction); + // Then it should return the correct text message + expect(result).toEqual(expectedResult); + }); + + it('return the message "moved expense from self DM to chat with ${reportName}" when only reportName is present', async () => { + // Given the policyExpenseChat with only reportName is present and report action + const policyExpenseChat = { + ...report, + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + isOwnPolicyExpenseChat: false, + }; + const reportAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, + originalMessage: { + movedToReportID: policyExpenseChat.reportID, + }, + }; + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat}); + await waitForBatchedUpdates(); + + // Given the correct text message + const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromSelfDM', {reportName: policyExpenseChat.reportName}); + + // When the expense is moved to an expense chat with only reportName is present + const result = ModifiedExpenseMessage.getForReportAction(policyExpenseChat.reportID, reportAction); + // Then it should return the correct text message + expect(result).toEqual(expectedResult); + }); }); }); }); From 637541355fb86431b3ea32138f73c6b60bd8181a Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Sun, 2 Feb 2025 15:44:09 +0700 Subject: [PATCH 06/10] fix: eslint fail --- tests/unit/ModifiedExpenseMessageTest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index 58bc6858740a..f7ce67486ec1 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -455,7 +455,7 @@ describe('ModifiedExpenseMessage', () => { expect(result).toEqual(expectedResult); }); - it('return the message "moved expense from self DM to ${policyName}" when both reportName and policyName are present', async () => { + it('return the message "moved expense from self DM to policyName" when both reportName and policyName are present', async () => { // Given the policyExpenseChat with both reportName and policyName are present and report action const policyExpenseChat = { ...report, @@ -482,7 +482,7 @@ describe('ModifiedExpenseMessage', () => { expect(result).toEqual(expectedResult); }); - it('return the message "moved expense from self DM to chat with ${reportName}" when only reportName is present', async () => { + it('return the message "moved expense from self DM to chat with reportName" when only reportName is present', async () => { // Given the policyExpenseChat with only reportName is present and report action const policyExpenseChat = { ...report, From d05f309adcc36b2cc343927a8ce27ac513097e57 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Mon, 3 Feb 2025 04:32:12 +0700 Subject: [PATCH 07/10] resolve request chagne --- tests/unit/ModifiedExpenseMessageTest.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index f7ce67486ec1..1b3de26795b0 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -419,7 +419,6 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`]: selfDMReport}); await waitForBatchedUpdates(); - // Given the correct text message const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.changedTheExpense'); // When the expense is moved from an expense chat or 1:1 DM to selfDM @@ -446,7 +445,6 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat}); await waitForBatchedUpdates(); - // Given the correct text message const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.changedTheExpense'); // When the expense is moved to an expense chat with reportName empty @@ -473,7 +471,6 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat}); await waitForBatchedUpdates(); - // Given the correct text message const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromSelfDM', {reportName: policyExpenseChat.reportName, workspaceName: policyExpenseChat.policyName}); // When the expense is moved to an expense chat with both reportName and policyName are present @@ -499,7 +496,6 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat}); await waitForBatchedUpdates(); - // Given the correct text message const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromSelfDM', {reportName: policyExpenseChat.reportName}); // When the expense is moved to an expense chat with only reportName is present From e0b024859972a6ecaa0bb0dec74e4dfe53547035 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Mon, 3 Feb 2025 20:18:47 +0700 Subject: [PATCH 08/10] fix: update the text to moved to self DM --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/ModifiedExpenseMessage.ts | 2 +- tests/unit/ModifiedExpenseMessageTest.ts | 6 +++--- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index f2e4428bb6ae..359eee0a491c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -996,6 +996,7 @@ const translations = { threadTrackReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Tracking ${formattedAmount} ${comment ? `for ${comment}` : ''}`, threadPaySomeoneReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`, movedFromSelfDM: ({workspaceName, reportName}: MovedFromSelfDMParams) => `moved expense from self DM to ${workspaceName ?? `chat with ${reportName}`}`, + movedToSelfDM: 'moved expense to self DM', tagSelection: 'Select a tag to better organize your spend.', categorySelection: 'Select a category to better organize your spend.', error: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 9e44e060487d..88cbe93db485 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -994,6 +994,7 @@ const translations = { threadTrackReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Seguimiento ${formattedAmount} ${comment ? `para ${comment}` : ''}`, threadPaySomeoneReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, movedFromSelfDM: ({workspaceName, reportName}: MovedFromSelfDMParams) => `movió el gasto desde su propio mensaje directo a ${workspaceName ?? `un chat con ${reportName}`}`, + movedToSelfDM: 'movió el gasto a su propio mensaje', tagSelection: 'Selecciona una etiqueta para organizar mejor tus gastos.', categorySelection: 'Selecciona una categoría para organizar mejor tus gastos.', error: { diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index f88c03eab9ac..c8ee0f3b22f0 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -145,7 +145,7 @@ function getForExpenseMovedFromSelfDM(destinationReportID: string) { // However, in the olddot, expenses could be moved back to a self-DM. // To maintain consistency and handle this case, we provide a fallback message. if (isSelfDM(rootParentReport)) { - return translateLocal('iou.changedTheExpense'); + return translateLocal('iou.movedToSelfDM'); } const reportName = isPolicyExpenseChat(rootParentReport) ? getPolicyExpenseChatName(rootParentReport) : buildReportNameFromParticipantNames({report: rootParentReport}); const policyName = getPolicyName(rootParentReport, true); diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index 1b3de26795b0..b9e1869c72c1 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -403,7 +403,7 @@ describe('ModifiedExpenseMessage', () => { describe('when moving an expense', () => { beforeEach(() => Onyx.clear()); - it('return the message "changed the expense" when moving an expense from an expense chat or 1:1 DM to selfDM', async () => { + it('return the message "moved expense to self DM" when moving an expense from an expense chat or 1:1 DM to selfDM', async () => { // Given the selfDM report and report action const selfDMReport = { ...report, @@ -419,11 +419,11 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`]: selfDMReport}); await waitForBatchedUpdates(); - const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.changedTheExpense'); + const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedToSelfDM'); // When the expense is moved from an expense chat or 1:1 DM to selfDM const result = ModifiedExpenseMessage.getForReportAction(selfDMReport.reportID, reportAction); - // Then it should return the 'changed the expense' message + // Then it should return the 'moved expense to self DM' message expect(result).toEqual(expectedResult); }); From cb33aa2c678bdd2dad504092492732df72a1ed76 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Mon, 3 Feb 2025 20:48:58 +0700 Subject: [PATCH 09/10] fix: change comment to be more suitable for the scenarios --- src/libs/ModifiedExpenseMessage.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index c8ee0f3b22f0..9acf9f964403 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -139,14 +139,13 @@ function getForDistanceRequest(newMerchant: string, oldMerchant: string, newAmou function getForExpenseMovedFromSelfDM(destinationReportID: string) { const destinationReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${destinationReportID}`]; const rootParentReport = getRootParentReport(destinationReport); - // The "Move report" flow only supports moving expenses from selfDM to: - // 1. A policy expense chat - // 2. A 1:1 DM - // However, in the olddot, expenses could be moved back to a self-DM. - // To maintain consistency and handle this case, we provide a fallback message. + // In OldDot, expenses could be moved to a self-DM. Return the corresponding message for this case. if (isSelfDM(rootParentReport)) { return translateLocal('iou.movedToSelfDM'); } + // In NewDot, the "Move report" flow only supports moving expenses from self-DM to: + // - A policy expense chat + // - A 1:1 DM const reportName = isPolicyExpenseChat(rootParentReport) ? getPolicyExpenseChatName(rootParentReport) : buildReportNameFromParticipantNames({report: rootParentReport}); const policyName = getPolicyName(rootParentReport, true); // If we can't determine either the report name or policy name, return the default message From 53e148af69f6acf392aa1362e02d9ff7bf135834 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Mon, 3 Feb 2025 21:06:45 +0700 Subject: [PATCH 10/10] fix: incorrect message --- 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 88cbe93db485..4e82ce7e16d8 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -994,7 +994,7 @@ const translations = { threadTrackReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Seguimiento ${formattedAmount} ${comment ? `para ${comment}` : ''}`, threadPaySomeoneReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, movedFromSelfDM: ({workspaceName, reportName}: MovedFromSelfDMParams) => `movió el gasto desde su propio mensaje directo a ${workspaceName ?? `un chat con ${reportName}`}`, - movedToSelfDM: 'movió el gasto a su propio mensaje', + movedToSelfDM: 'movió el gasto a su propio mensaje directo', tagSelection: 'Selecciona una etiqueta para organizar mejor tus gastos.', categorySelection: 'Selecciona una categoría para organizar mejor tus gastos.', error: {