Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6fff359
Implemented company address policy change log message formatting in R…
rayane-d Dec 10, 2025
3a35816
add translations
rayane-d Dec 10, 2025
914a2c5
fix failing check
rayane-d Dec 10, 2025
c3d3453
Merge branch 'main' into company-address-changelog
rayane-d Dec 12, 2025
0adad94
Merge branch 'Expensify:main' into company-address-changelog
rayane-d Dec 15, 2025
f0ca33b
Merge branch 'main' into company-address-changelog
rayane-d Dec 24, 2025
04f46c2
implement unit tests for getCompanyAddressUpdateMessage
rayane-d Dec 24, 2025
46df495
simplify test
rayane-d Dec 24, 2025
2123732
added a comment
rayane-d Dec 24, 2025
f5a637e
fix lint error
rayane-d Dec 24, 2025
d713f50
prettier
rayane-d Dec 24, 2025
4917736
Merge branch 'main' into company-address-changelog
rayane-d Jan 2, 2026
7a6984f
Merge branch 'main' into company-address-changelog
rayane-d Jan 7, 2026
cf4515a
Refactor getCompanyAddressUpdateMessage to accept translate function …
rayane-d Jan 7, 2026
de32ef0
Remove duplicated imports
rayane-d Jan 7, 2026
7bed61f
add missing import
rayane-d Jan 7, 2026
58dcb81
fix merge conflicts
rayane-d Jan 7, 2026
1163603
fix "Changed files ESLint check" error
rayane-d Jan 7, 2026
c7dae41
Merge branch 'main' into company-address-changelog
rayane-d Jan 8, 2026
78eb809
Merge branch 'main' into company-address-changelog
rayane-d Jan 9, 2026
112685f
Merge branch 'main' into company-address-changelog
rayane-d Jan 11, 2026
cf54a08
Merge branch 'Expensify:main' into company-address-changelog
rayane-d Jan 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ const CONST = {
UPDATE_DISABLED_FIELDS: 'POLICYCHANGELOG_UPDATE_DISABLED_FIELDS',
UPDATE_EMPLOYEE: 'POLICYCHANGELOG_UPDATE_EMPLOYEE',
UPDATE_FIELD: 'POLICYCHANGELOG_UPDATE_FIELD',
UPDATE_ADDRESS: 'POLICYCHANGELOG_UPDATE_ADDRESS',
UPDATE_FEATURE_ENABLED: 'POLICYCHANGELOG_UPDATE_FEATURE_ENABLED',
UPDATE_IS_ATTENDEE_TRACKING_ENABLED: 'POLICYCHANGELOG_UPDATE_IS_ATTENDEE_TRACKING_ENABLED',
UPDATE_DEFAULT_APPROVER: 'POLICYCHANGELOG_UPDATE_DEFAULT_APPROVER',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6331,6 +6331,8 @@ Fordere Spesendetails wie Belege und Beschreibungen an, lege Limits und Standard
billcom: 'BILLCOM',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `Firmenadresse geändert zu „${newAddress}“ (zuvor „${previousAddress}“)` : `Unternehmensadresse auf „${newAddress}“ festlegen`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
`${approverName} (${approverEmail}) als Genehmiger für das Feld ${field} „${name}“ hinzugefügt`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6208,6 +6208,8 @@ const translations = {
billcom: 'BILLCOM',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `changed the company address to "${newAddress}" (previously "${previousAddress}")` : `set the company address to "${newAddress}"`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) => `added ${approverName} (${approverEmail}) as an approver for the ${field} "${name}"`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
`removed ${approverName} (${approverEmail}) as an approver for the ${field} "${name}"`,
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5951,6 +5951,8 @@ ${amount} para ${merchant} - ${date}`,
billcom: 'BILLCOM',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `cambió la dirección de la empresa a "${newAddress}" (anteriormente "${previousAddress}")` : `estableció la dirección de la empresa en "${newAddress}"`,
addApprovalRule: (approverEmail, approverName, field, name) => `añadió a ${approverName} (${approverEmail}) como aprobador para la ${field} "${name}"`,
deleteApprovalRule: (approverEmail, approverName, field, name) => `eliminó a ${approverName} (${approverEmail}) como aprobador para la ${field} "${name}"`,
updateApprovalRule: ({field, name, newApproverEmail, newApproverName, oldApproverEmail, oldApproverName}) => {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6340,6 +6340,8 @@ Exigez des informations de dépense comme les reçus et les descriptions, défin
billcom: 'BILLCOM',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `a modifié l’adresse de l’entreprise en « ${newAddress} » (auparavant « ${previousAddress} »)` : `définir l’adresse de l’entreprise sur « ${newAddress} »`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
`a ajouté ${approverName} (${approverEmail}) comme approbateur pour le ${field} « ${name} »`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
Expand Down
2 changes: 2 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6315,6 +6315,8 @@ Richiedi dettagli di spesa come ricevute e descrizioni, imposta limiti e valori
billcom: 'BILLCOM',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `ha modificato l’indirizzo dell’azienda in "${newAddress}" (precedentemente "${previousAddress}")` : `imposta l’indirizzo dell’azienda su "${newAddress}"`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
`ha aggiunto ${approverName} (${approverEmail}) come approvatore per il campo ${field} "${name}"`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
Expand Down
2 changes: 2 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6270,6 +6270,8 @@ ${reportName}
billcom: 'Bill.com',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `会社住所を「${newAddress}」(以前は「${previousAddress}」)に変更しました` : `会社の住所を「${newAddress}」に設定`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) => `${field}「${name}」の承認者として${approverName}(${approverEmail})を追加しました`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
`${field}「${name}」の承認者として${approverName}(${approverEmail})を削除しました`,
Expand Down
2 changes: 2 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6304,6 +6304,8 @@ Vraag verplichte uitgavedetails zoals bonnetjes en beschrijvingen, stel limieten
billcom: 'Bill.com',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `het bedrijfsadres gewijzigd naar "${newAddress}" (voorheen "${previousAddress}")` : `stel het bedrijfsadres in op "${newAddress}"`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
`${approverName} (${approverEmail}) toegevoegd als goedkeurder voor het veld ${field} "${name}"`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
Expand Down
2 changes: 2 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6292,6 +6292,8 @@ Wymagaj szczegółów wydatków, takich jak paragony i opisy, ustawiaj limity i
billcom: 'Bill.com',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `zmienił adres firmy na „${newAddress}” (wcześniej „${previousAddress}”)` : `ustaw adres firmy na „${newAddress}”`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
`dodano ${approverName} (${approverEmail}) jako osobę zatwierdzającą dla pola ${field} „${name}”`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
Expand Down
2 changes: 2 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6294,6 +6294,8 @@ Exija detalhes de despesas como recibos e descrições, defina limites e padrõe
billcom: 'BILLCOM',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `alterou o endereço da empresa para "${newAddress}" (anteriormente "${previousAddress}")` : `definir o endereço da empresa como "${newAddress}"`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) =>
`adicionou ${approverName} (${approverEmail}) como aprovador para o campo ${field} "${name}"`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) => `removeu ${approverName} (${approverEmail}) como aprovador para ${field} "${name}"`,
Expand Down
2 changes: 2 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6169,6 +6169,8 @@ ${reportName}
billcom: 'BILLCOM',
},
workspaceActions: {
changedCompanyAddress: ({newAddress, previousAddress}: {newAddress: string; previousAddress?: string}) =>
previousAddress ? `将公司地址更改为“${newAddress}”(原为“${previousAddress}”)` : `将公司地址设置为“${newAddress}”`,
addApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) => `已将 ${approverName}(${approverEmail})添加为字段 ${field}“${name}”的审批人`,
deleteApprovalRule: (approverEmail: string, approverName: string, field: string, name: string) => `已将 ${approverName}(${approverEmail})从 ${field}“${name}”的审批人中移除`,
updateApprovalRule: ({field, name, newApproverEmail, newApproverName, oldApproverEmail, oldApproverName}: UpdatedPolicyApprovalRuleParams) => {
Expand Down
63 changes: 63 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import type {ValueOf} from 'type-fest';
import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider';
import usePrevious from '@hooks/usePrevious';
import {isHarvestCreatedExpenseReport, isPolicyExpenseChat} from '@libs/ReportUtils';

Check warning on line 10 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unexpected subpath import via alias '@libs/ReportUtils'. Use './ReportUtils' instead
import CONST from '@src/CONST';
import IntlStore from '@src/languages/IntlStore';
import type {TranslationPaths} from '@src/languages/types';
Expand Down Expand Up @@ -66,7 +66,7 @@
type MemberChangeMessageElement = MessageTextElement | MemberChangeMessageUserMentionElement | MemberChangeMessageRoomReferenceElement;

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 69 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -78,7 +78,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 81 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -87,13 +87,13 @@
});

let isNetworkOffline = false;
Onyx.connect({

Check warning on line 90 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NETWORK,
callback: (val) => (isNetworkOffline = val?.isOffline ?? false),
});

let deprecatedCurrentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 96 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, value is undefined
Expand Down Expand Up @@ -2942,6 +2942,68 @@
return getReportActionText(action);
}

type CompanyAddressOriginalMessage = {
newAddress: {addressStreet?: string; city?: string; state?: string; zipCode?: string; country?: string};
oldAddress?: {addressStreet?: string; city?: string; state?: string; zipCode?: string; country?: string} | null;
};

/**
* Format address as "street1, street2 (if exists), city, state zipCode"
*/
function formatAddressToString(address: CompanyAddressOriginalMessage['newAddress'] | null | undefined): string {
if (!address) {
return '';
}

Comment thread
rayane-d marked this conversation as resolved.
const [street1Raw, street2Raw] = (address.addressStreet ?? '').split('\n');
const street1 = street1Raw?.trim() ?? '';
const street2 = street2Raw?.trim() ?? '';
Comment thread
rayane-d marked this conversation as resolved.

const parts: string[] = [];

if (street1) {
parts.push(street1);
}
if (street2) {
parts.push(street2);
}
if (address.city) {
parts.push(address.city);
}

let stateZip = '';
if (address.state) {
stateZip = address.state;
if (address.zipCode) {
stateZip += ` ${address.zipCode}`;
}
} else if (address.zipCode) {
stateZip = address.zipCode;
}

if (stateZip) {
parts.push(stateZip);
}

return parts.join(', ');
}

function getCompanyAddressUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string {
const originalMessage = getOriginalMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ADDRESS>) as CompanyAddressOriginalMessage | undefined;

if (!originalMessage) {
return getReportActionText(action);
}

const newAddressStr = formatAddressToString(originalMessage.newAddress);
const oldAddressStr = formatAddressToString(originalMessage.oldAddress);
Comment thread
rayane-d marked this conversation as resolved.

return translate('workspaceActions.changedCompanyAddress', {
newAddress: newAddressStr,
Comment thread
rayane-d marked this conversation as resolved.
previousAddress: oldAddressStr || undefined,
});
}

function getWorkspaceFeatureEnabledMessage(translate: LocalizedTranslate, action: ReportAction): string {
const {enabled, featureName} = getOriginalMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FEATURE_ENABLED>) ?? {};

Expand Down Expand Up @@ -3694,6 +3756,7 @@
getWorkspaceUpdateFieldMessage,
getWorkspaceFeatureEnabledMessage,
getWorkspaceAttendeeTrackingUpdateMessage,
getCompanyAddressUpdateMessage,
getDefaultApproverUpdateMessage,
getSubmitsToUpdateMessage,
getForwardsToUpdateMessage,
Expand Down
5 changes: 5 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ import {
getAllReportActions,
getCardIssuedMessage,
getChangedApproverActionMessage,
getCompanyAddressUpdateMessage,
getCompanyCardConnectionBrokenMessage,
getCreatedReportForUnapprovedTransactionsMessage,
getDefaultApproverUpdateMessage,
Expand Down Expand Up @@ -5739,6 +5740,10 @@ function getReportName(
// eslint-disable-next-line @typescript-eslint/no-deprecated
return getActionableCardFraudAlertResolutionMessage(translateLocal, parentReportAction);
}
if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ADDRESS)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return getCompanyAddressUpdateMessage(translateLocal, parentReportAction);
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) {
return getMarkedReimbursedMessage(parentReportAction);
Expand Down
3 changes: 3 additions & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
getAddedConnectionMessage,
getCardIssuedMessage,
getChangedApproverActionMessage,
getCompanyAddressUpdateMessage,
getCompanyCardConnectionBrokenMessage,
getDefaultApproverUpdateMessage,
getDeletedApprovalRuleMessage,
Expand Down Expand Up @@ -908,6 +909,8 @@ function getOptionData({
result.alternateText = getForwardsToUpdateMessage(translate, lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REIMBURSEMENT_ENABLED) {
result.alternateText = getWorkspaceReimbursementUpdateMessage(translate, lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ADDRESS) {
result.alternateText = getCompanyAddressUpdateMessage(translate, lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) {
result.alternateText = getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(translate, lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
getAddedConnectionMessage,
getCardIssuedMessage,
getChangedApproverActionMessage,
getCompanyAddressUpdateMessage,
getCompanyCardConnectionBrokenMessage,
getCreatedReportForUnapprovedTransactionsMessage,
getDefaultApproverUpdateMessage,
Expand Down Expand Up @@ -747,6 +748,8 @@ const ContextMenuActions: ContextMenuAction[] = [
Clipboard.setString(getForwardsToUpdateMessage(translate, reportAction));
} else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REIMBURSEMENT_ENABLED) {
Clipboard.setString(getWorkspaceReimbursementUpdateMessage(translate, reportAction));
} else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ADDRESS) {
Clipboard.setString(getCompanyAddressUpdateMessage(translate, reportAction));
} else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) {
Clipboard.setString(getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(translate, reportAction));
} else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import {
getAddedApprovalRuleMessage,
getAddedConnectionMessage,
getChangedApproverActionMessage,
getCompanyAddressUpdateMessage,
getCompanyCardConnectionBrokenMessage,
getCreatedReportForUnapprovedTransactionsMessage,
getDefaultApproverUpdateMessage,
Expand Down Expand Up @@ -1456,6 +1457,8 @@ function PureReportActionItem({
children = <ReportActionItemBasicMessage message={getForwardsToUpdateMessage(translate, action)} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REIMBURSEMENT_ENABLED)) {
children = <ReportActionItemBasicMessage message={getWorkspaceReimbursementUpdateMessage(translate, action)} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ADDRESS)) {
children = <ReportActionItemBasicMessage message={getCompanyAddressUpdateMessage(translate, action)} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) {
children = <ReportActionItemBasicMessage message={getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(translate, action)} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) {
Expand Down
73 changes: 73 additions & 0 deletions tests/unit/ReportActionsUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import CONST from '../../src/CONST';
import * as ReportActionsUtils from '../../src/libs/ReportActionsUtils';
import {
getCardIssuedMessage,
getCompanyAddressUpdateMessage,
getCreatedReportForUnapprovedTransactionsMessage,
getOneTransactionThreadReportID,
getOriginalMessage,
Expand Down Expand Up @@ -2284,6 +2285,78 @@ describe('ReportActionsUtils', () => {
});
});

describe('getCompanyAddressUpdateMessage', () => {
it('should return "set" message when setting address for first time', () => {
const action = {
actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ADDRESS,
reportActionID: '1',
created: '',
originalMessage: {
newAddress: {
addressStreet: '123 Main St',
city: 'San Francisco',
state: 'CA',
zipCode: '94102',
country: 'US',
},
oldAddress: null,
},
} as ReportAction;

const result = getCompanyAddressUpdateMessage(translateLocal, action);
expect(result).toBe('set the company address to "123 Main St, San Francisco, CA 94102"');
});

it('should return "changed" message when updating existing address', () => {
const action = {
actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ADDRESS,
reportActionID: '1',
created: '',
originalMessage: {
newAddress: {
addressStreet: '456 New Ave',
city: 'Los Angeles',
state: 'CA',
zipCode: '90001',
country: 'US',
},
oldAddress: {
addressStreet: '123 Old St',
city: 'San Francisco',
state: 'CA',
zipCode: '94102',
country: 'US',
},
},
} as ReportAction;

const result = getCompanyAddressUpdateMessage(translateLocal, action);
expect(result).toBe('changed the company address to "456 New Ave, Los Angeles, CA 90001" (previously "123 Old St, San Francisco, CA 94102")');
});
it('should handle address with street2 (newline separated)', () => {
const action = {
actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ADDRESS,
reportActionID: '1',
created: '',
originalMessage: {
newAddress: {
addressStreet: '123 Main St\nSuite 500',
city: 'New York',
state: 'NY',
zipCode: '10001',
country: 'US',
},
oldAddress: null,
},
} as ReportAction;

const result = getCompanyAddressUpdateMessage(translateLocal, action);

// The new line should be replaced with a comma
expect(result).toBe('set the company address to "123 Main St, Suite 500, New York, NY 10001"');
});
});

describe('getWorkspaceCustomUnitRateUpdatedMessage', () => {
it('should return the correct message when a rate is enabled', () => {
const action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT_RATE> = {
Expand Down
Loading