Skip to content

Commit

Permalink
fix: update system message when move expense
Browse files Browse the repository at this point in the history
  • Loading branch information
linhvovan29546 committed Feb 7, 2025
1 parent 6bd0e4e commit d81d071
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import type {
MarkedReimbursedParams,
MarkReimbursedFromIntegrationParams,
MissingPropertyParams,
MovedFromSelfDMParams,
MovedFromPersonalSpaceParams,
NoLongerHaveAccessParams,
NotAllowedExtensionParams,
NotYouParams,
Expand Down Expand Up @@ -995,8 +995,8 @@ const translations = {
threadExpenseReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${formattedAmount} ${comment ? `for ${comment}` : 'expense'}`,
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 personal space to ${workspaceName ?? `chat with ${reportName}`}`,
movedToSelfDM: 'moved expense from expense report to your personal space',
movedFromPersonalSpace: ({workspaceName, reportName}: MovedFromPersonalSpaceParams) => `moved expense from personal space to ${workspaceName ?? `chat with ${reportName}`}`,
movedToPersonalSpace: 'moved expense to personal space',
tagSelection: 'Select a tag to better organize your spend.',
categorySelection: 'Select a category to better organize your spend.',
error: {
Expand Down
6 changes: 3 additions & 3 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ import type {
MarkedReimbursedParams,
MarkReimbursedFromIntegrationParams,
MissingPropertyParams,
MovedFromSelfDMParams,
MovedFromPersonalSpaceParams,
NoLongerHaveAccessParams,
NotAllowedExtensionParams,
NotYouParams,
Expand Down Expand Up @@ -993,8 +993,8 @@ const translations = {
threadExpenseReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${comment ? `${formattedAmount} para ${comment}` : `Gasto de ${formattedAmount}`}`,
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 el espacio personal a ${workspaceName ?? `un chat con ${reportName}`}`,
movedToSelfDM: 'movió el gasto del informe de gastos a tu espacio personal',
movedFromPersonalSpace: ({workspaceName, reportName}: MovedFromPersonalSpaceParams) => `movió el gasto desde su espacio personal a ${workspaceName ?? `un chat con ${reportName}`}`,
movedToPersonalSpace: 'movió el gasto a su espacio personal',
tagSelection: 'Selecciona una etiqueta para organizar mejor tus gastos.',
categorySelection: 'Selecciona una categoría para organizar mejor tus gastos.',
error: {
Expand Down
4 changes: 2 additions & 2 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ type ThreadRequestReportNameParams = {formattedAmount: string; comment: string};

type ThreadSentMoneyReportNameParams = {formattedAmount: string; comment: string};

type MovedFromSelfDMParams = {workspaceName?: string; reportName?: string};
type MovedFromPersonalSpaceParams = {workspaceName?: string; reportName?: string};

type SizeExceededParams = {maxUploadSizeInMB: number};

Expand Down Expand Up @@ -705,7 +705,7 @@ export type {
LoggedInAsParams,
ManagerApprovedAmountParams,
ManagerApprovedParams,
MovedFromSelfDMParams,
MovedFromPersonalSpaceParams,
SignUpNewFaceCodeParams,
NoLongerHaveAccessParams,
NotAllowedExtensionParams,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ModifiedExpenseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function getForExpenseMovedFromSelfDM(destinationReportID: string) {
const rootParentReport = getRootParentReport({report: destinationReport});
// In OldDot, expenses could be moved to a self-DM. Return the corresponding message for this case.
if (isSelfDM(rootParentReport)) {
return translateLocal('iou.movedToSelfDM');
return translateLocal('iou.movedToPersonalSpace');
}
// In NewDot, the "Move report" flow only supports moving expenses from self-DM to:
// - A policy expense chat
Expand All @@ -152,7 +152,7 @@ function getForExpenseMovedFromSelfDM(destinationReportID: string) {
if (isEmpty(policyName) && !reportName) {
return translateLocal('iou.changedTheExpense');
}
return translateLocal('iou.movedFromSelfDM', {
return translateLocal('iou.movedFromPersonalSpace', {
reportName,
workspaceName: !isEmpty(policyName) ? policyName : undefined,
});
Expand Down
15 changes: 9 additions & 6 deletions tests/unit/ModifiedExpenseMessageTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ describe('ModifiedExpenseMessage', () => {

describe('when moving an expense', () => {
beforeEach(() => Onyx.clear());
it('return the message "moved expense from expense report to your personal space" when moving an expense from an expense chat or 1:1 DM to selfDM', async () => {
it('return the message "moved expense to personal space" 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,
Expand All @@ -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.movedToSelfDM');
const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedToPersonalSpace');

// When the expense is moved from an expense chat or 1:1 DM to selfDM
const result = ModifiedExpenseMessage.getForReportAction({reportOrID: selfDMReport.reportID, reportAction});
// Then it should return the 'moved expense to self DM' message
// Then it should return the correct text message
expect(result).toEqual(expectedResult);
});

Expand All @@ -449,7 +449,7 @@ describe('ModifiedExpenseMessage', () => {

// When the expense is moved to an expense chat with reportName empty
const result = ModifiedExpenseMessage.getForReportAction({reportOrID: policyExpenseChat.reportID, reportAction});
// Then it should return the 'changed the expense' message
// Then it should return the correct text message
expect(result).toEqual(expectedResult);
});

Expand All @@ -471,7 +471,10 @@ describe('ModifiedExpenseMessage', () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat});
await waitForBatchedUpdates();

const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromSelfDM', {reportName: policyExpenseChat.reportName, workspaceName: policyExpenseChat.policyName});
const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromPersonalSpace', {
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({reportOrID: policyExpenseChat.reportID, reportAction});
Expand All @@ -496,7 +499,7 @@ describe('ModifiedExpenseMessage', () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat});
await waitForBatchedUpdates();

const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromSelfDM', {reportName: policyExpenseChat.reportName});
const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromPersonalSpace', {reportName: policyExpenseChat.reportName});

// When the expense is moved to an expense chat with only reportName is present
const result = ModifiedExpenseMessage.getForReportAction({reportOrID: policyExpenseChat.reportID, reportAction});
Expand Down

0 comments on commit d81d071

Please sign in to comment.