Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 7 additions & 6 deletions src/libs/ModifiedExpenseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,16 +674,16 @@ function getForReportActionTemp({

const hasModifiedTag = isReportActionOriginalMessageAnObject && 'oldTag' in reportActionOriginalMessage && 'tag' in reportActionOriginalMessage;
if (hasModifiedTag) {
const policyTagsToUse = policyTags ?? CONST.POLICY.DEFAULT_TAG_LIST;
const transactionTag = reportActionOriginalMessage?.tag ?? '';
const oldTransactionTag = reportActionOriginalMessage?.oldTag ?? '';
const splittedTag = getTagArrayFromName(transactionTag);
const splittedOldTag = getTagArrayFromName(oldTransactionTag);
const localizedTagListName = translate('common.tag');
const sortedTagKeys = getSortedTagKeys(policyTags);
const sortedTagKeys = getSortedTagKeys(policyTagsToUse);

for (const [index, policyTagKey] of sortedTagKeys.entries()) {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const policyTagListName = policyTags?.[policyTagKey]?.name || localizedTagListName;
const policyTagListName = policyTagsToUse[policyTagKey].name || localizedTagListName;

const newTag = splittedTag.at(index) ?? '';
const oldTag = splittedOldTag.at(index) ?? '';
Expand Down Expand Up @@ -751,10 +751,11 @@ function getForReportActionTemp({

const hasPolicyRulesModifiedFields = isReportActionOriginalMessageAnObject && 'policyRulesModifiedFields' in reportActionOriginalMessage && 'policyID' in reportActionOriginalMessage;
if (hasPolicyRulesModifiedFields) {
const {policyRulesModifiedFields, policyID} = reportActionOriginalMessage;
const rulePolicyID = reportActionOriginalMessage.policyID;
const policyRulesModifiedFields = reportActionOriginalMessage.policyRulesModifiedFields;

if (policyRulesModifiedFields && policyID) {
return getPolicyRulesModifiedMessage(translate, policyRulesModifiedFields, policyID);
if (policyRulesModifiedFields && rulePolicyID) {
return getPolicyRulesModifiedMessage(translate, policyRulesModifiedFields, rulePolicyID);
}
}

Expand Down
30 changes: 22 additions & 8 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {appendCountryCode, getPhoneNumberWithoutSpecialChars} from '@libs/LoginUtils';
import {MaxHeap} from '@libs/MaxHeap';
import {MinHeap} from '@libs/MinHeap';
import {getForReportAction} from '@libs/ModifiedExpenseMessage';
import {getForReportAction, getForReportActionTemp} from '@libs/ModifiedExpenseMessage';
import Navigation from '@libs/Navigation/Navigation';
import Parser from '@libs/Parser';
import Performance from '@libs/Performance';
Expand Down Expand Up @@ -198,13 +198,13 @@
*/

let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 201 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 201 in src/libs/OptionsListUtils/index.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.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = isEmptyObject(value) ? {} : value),
});

const policies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 207 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 207 in src/libs/OptionsListUtils/index.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.POLICY,
callback: (policy, key) => {
if (!policy || !key || !policy.name) {
Expand All @@ -216,7 +216,7 @@
});

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

Check warning on line 219 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 219 in src/libs/OptionsListUtils/index.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 @@ -225,7 +225,7 @@
});

let allReportNameValuePairsOnyxConnect: OnyxCollection<ReportNameValuePairs>;
Onyx.connect({

Check warning on line 228 in src/libs/OptionsListUtils/index.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_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -237,7 +237,7 @@
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const lastVisibleReportActions: ReportActions = {};
Onyx.connect({

Check warning on line 240 in src/libs/OptionsListUtils/index.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 Down Expand Up @@ -299,7 +299,7 @@
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 302 in src/libs/OptionsListUtils/index.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.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});
Expand Down Expand Up @@ -603,6 +603,8 @@
policyForMovingExpensesID,
reportMetadata,
reportAttributesDerived,
policyTags,
currentUserLogin,
}: {
translate: LocalizedTranslate;
report: OnyxEntry<Report>;
Expand All @@ -614,6 +616,8 @@
policyForMovingExpensesID?: string;
reportMetadata?: OnyxEntry<ReportMetadata>;
reportAttributesDerived?: ReportAttributesDerivedValue['reports'];
policyTags?: OnyxEntry<PolicyTagLists>;
currentUserLogin?: string;
}): string {
const reportID = report?.reportID;
const lastReportAction = reportID ? lastVisibleReportActions[reportID] : undefined;
Expand Down Expand Up @@ -687,13 +691,23 @@
} else if (isReportMessageAttachment({text: report?.lastMessageText ?? '', html: report?.lastMessageHtml, type: ''})) {
lastMessageTextFromReport = `[${translate('common.attachment')}]`;
} else if (isModifiedExpenseAction(lastReportAction)) {
const properSchemaForModifiedExpenseMessage = getForReportAction({
reportAction: lastReportAction,
policyID: report?.policyID,
movedFromReport,
movedToReport,
policyForMovingExpensesID,
});
const properSchemaForModifiedExpenseMessage = policyTags
? getForReportActionTemp({
translate,
reportAction: lastReportAction,
policy,
movedFromReport,
movedToReport,
policyTags,
currentUserLogin: currentUserLogin ?? '',
})
: getForReportAction({
reportAction: lastReportAction,
policyID: report?.policyID,
movedFromReport,
movedToReport,
policyForMovingExpensesID,
});
lastMessageTextFromReport = formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true);
} else if (isMovedTransactionAction(lastReportAction)) {
lastMessageTextFromReport = Parser.htmlToText(getMovedTransactionMessage(translate, lastReportAction));
Expand Down
Loading