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
41 changes: 16 additions & 25 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@
getDeletedParentActionMessageForChatReport,
getDeletedTransactionMessage,
getDisplayNameForParticipant,
getDowngradeWorkspaceMessage,
getForcedCorporateUpgradeMessage,
getIcons,
getMovedActionMessage,
getMovedTransactionMessage,
Expand All @@ -110,14 +108,12 @@
getPolicyName,
getReimbursementDeQueuedOrCanceledActionMessage,
getReimbursementQueuedActionMessage,
getRejectedReportMessage,
getReportLastMessage,
getReportNotificationPreference,
getReportOrDraftReport,
getReportPreviewMessage,
getReportSubtitlePrefix,
getUnreportedTransactionMessage,
getUpgradeWorkspaceMessage,
hasIOUWaitingOnCurrentUserBankAccount,
isArchivedNonExpenseReport,
isChatThread,
Expand Down Expand Up @@ -196,7 +192,7 @@
*/
let currentUserLogin: string | undefined;
let currentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 195 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.SESSION,
callback: (value) => {
currentUserLogin = value?.email;
Expand All @@ -205,13 +201,13 @@
});

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

Check warning on line 204 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 210 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 @@ -223,14 +219,14 @@
});

let allPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 222 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,
waitForCollectionCallback: true,
callback: (val) => (allPolicies = val),
});

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

Check warning on line 229 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 @@ -239,7 +235,7 @@
});

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

Check warning on line 238 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 @@ -251,7 +247,7 @@
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const lastVisibleReportActions: ReportActions = {};
Onyx.connect({

Check warning on line 250 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 @@ -313,7 +309,7 @@
});

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

Check warning on line 312 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 @@ -684,9 +680,9 @@
lastMessageTextFromReport = formatReportLastMessageText(Parser.htmlToText(reportPreviewMessage));
}
} else if (isReimbursementQueuedAction(lastReportAction)) {
lastMessageTextFromReport = getReimbursementQueuedActionMessage({reportAction: lastReportAction, formatPhoneNumber: formatPhoneNumberPhoneUtils, reportOrID: report});
lastMessageTextFromReport = getReimbursementQueuedActionMessage({reportAction: lastReportAction, translate, formatPhoneNumber: formatPhoneNumberPhoneUtils, report});
} else if (isReimbursementDeQueuedOrCanceledAction(lastReportAction)) {
lastMessageTextFromReport = getReimbursementDeQueuedOrCanceledActionMessage(lastReportAction, report);
lastMessageTextFromReport = getReimbursementDeQueuedOrCanceledActionMessage(translate, lastReportAction, report);
} else if (isDeletedParentAction(lastReportAction) && reportUtilsIsChatReport(report)) {
lastMessageTextFromReport = getDeletedParentActionMessageForChatReport(lastReportAction);
} else if (isPendingRemove(lastReportAction) && report?.reportID && isThreadParentMessage(lastReportAction, report.reportID)) {
Expand All @@ -705,7 +701,7 @@
});
lastMessageTextFromReport = formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true);
} else if (isMovedTransactionAction(lastReportAction)) {
lastMessageTextFromReport = Parser.htmlToText(getMovedTransactionMessage(lastReportAction));
lastMessageTextFromReport = Parser.htmlToText(getMovedTransactionMessage(translate, lastReportAction));
} else if (isTaskAction(lastReportAction)) {
lastMessageTextFromReport = formatReportLastMessageText(getTaskReportActionMessage(translate, lastReportAction).text);
} else if (isCreatedTaskReportAction(lastReportAction)) {
Expand Down Expand Up @@ -745,13 +741,13 @@
lastMessageTextFromReport = translate('iou.forwarded');
}
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) {
lastMessageTextFromReport = getRejectedReportMessage();
lastMessageTextFromReport = translate('iou.rejectedThisReport');
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) {
lastMessageTextFromReport = getUpgradeWorkspaceMessage();
lastMessageTextFromReport = translate('workspaceActions.upgradedWorkspace');
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_FORCE_UPGRADE) {
lastMessageTextFromReport = Parser.htmlToText(getForcedCorporateUpgradeMessage());
lastMessageTextFromReport = Parser.htmlToText(translate('workspaceActions.forcedCorporateUpgrade'));
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) {
lastMessageTextFromReport = getDowngradeWorkspaceMessage();
lastMessageTextFromReport = translate('workspaceActions.downgradedWorkspace');
} else if (isActionableAddPaymentCard(lastReportAction)) {
lastMessageTextFromReport = getReportActionMessageText(lastReportAction);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) {
Expand All @@ -775,45 +771,40 @@
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.REOPENED)) {
lastMessageTextFromReport = translate('iou.reopened');
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY)) {
lastMessageTextFromReport = getPolicyChangeMessage(lastReportAction);
lastMessageTextFromReport = getPolicyChangeMessage(translate, lastReportAction);
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) {
lastMessageTextFromReport = getTravelUpdateMessage(translate, lastReportAction);
} else if (isInviteOrRemovedAction(lastReportAction)) {
lastMessageTextFromReport = getRoomChangeLogMessage(translate, lastReportAction);
} else if (isRenamedAction(lastReportAction)) {
lastMessageTextFromReport = getRenamedAction(translate, lastReportAction, isExpenseReport(report));
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION)) {
lastMessageTextFromReport = getDeletedTransactionMessage(lastReportAction);
lastMessageTextFromReport = getDeletedTransactionMessage(translate, lastReportAction);
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) {
lastMessageTextFromReport = Parser.htmlToText(getChangedApproverActionMessage(translate, lastReportAction));
} else if (isMovedAction(lastReportAction)) {
lastMessageTextFromReport = Parser.htmlToText(getMovedActionMessage(lastReportAction, report));
lastMessageTextFromReport = Parser.htmlToText(getMovedActionMessage(translate, lastReportAction, report));
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION)) {
lastMessageTextFromReport = Parser.htmlToText(getUnreportedTransactionMessage(lastReportAction));
lastMessageTextFromReport = Parser.htmlToText(getUnreportedTransactionMessage(translate, lastReportAction));
} else if (isActionableMentionWhisper(lastReportAction)) {
lastMessageTextFromReport = Parser.htmlToText(getActionableMentionWhisperMessage(translate, lastReportAction));
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED)) {
lastMessageTextFromReport = getDynamicExternalWorkflowRoutedMessage(lastReportAction, translate);
}
if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
lastMessageTextFromReport = getPolicyChangeLogMaxExpenseAmountMessage(translateLocal, lastReportAction);
lastMessageTextFromReport = getPolicyChangeLogMaxExpenseAmountMessage(translate, lastReportAction);
}
if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AGE)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
lastMessageTextFromReport = getPolicyChangeLogMaxExpenseAgeMessage(translateLocal, lastReportAction);
lastMessageTextFromReport = getPolicyChangeLogMaxExpenseAgeMessage(translate, lastReportAction);
}
if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_ACH_ACCOUNT)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
lastMessageTextFromReport = getUpdateACHAccountMessage(translateLocal, lastReportAction);
lastMessageTextFromReport = getUpdateACHAccountMessage(translate, lastReportAction);
}
if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_INVOICE_COMPANY_NAME)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
lastMessageTextFromReport = getInvoiceCompanyNameUpdateMessage(translateLocal, lastReportAction);
lastMessageTextFromReport = getInvoiceCompanyNameUpdateMessage(translate, lastReportAction);
}
if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_INVOICE_COMPANY_WEBSITE)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
lastMessageTextFromReport = getInvoiceCompanyWebsiteUpdateMessage(translateLocal, lastReportAction);
lastMessageTextFromReport = getInvoiceCompanyWebsiteUpdateMessage(translate, lastReportAction);
}

// we do not want to show report closed in LHN for non archived report so use getReportLastMessage as fallback instead of lastMessageText from report
Expand Down
35 changes: 13 additions & 22 deletions src/libs/ReportNameUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,15 @@
import {
formatReportLastMessageText,
getDisplayNameForParticipant,
getDowngradeWorkspaceMessage,
getMoneyRequestSpendBreakdown,
getMovedActionMessage,
getParentReport,
getPolicyChangeMessage,
getPolicyName,
getRejectedReportMessage,
getReportMetadata,
getReportOrDraftReport,
getTransactionReportName,
getUnreportedTransactionMessage,
getUpgradeWorkspaceMessage,
getWorkspaceNameUpdatedMessage,
hasNonReimbursableTransactions,
isAdminRoom,
Expand Down Expand Up @@ -124,7 +121,7 @@

let allPersonalDetails: OnyxEntry<PersonalDetailsList>;

Onyx.connect({

Check warning on line 124 in src/libs/ReportNameUtils.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 = value;
Expand Down Expand Up @@ -390,7 +387,7 @@
return translate('iou.forwarded');
}
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) {
return getRejectedReportMessage();
return translate('iou.rejectedThisReport');
}
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RETRACTED) {
return translate('iou.retracted');
Expand All @@ -399,10 +396,10 @@
return translate('iou.reopened');
}
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) {
return getUpgradeWorkspaceMessage();
return translate('workspaceActions.upgradedWorkspace');
}
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) {
return getDowngradeWorkspaceMessage();
return translate('workspaceActions.downgradedWorkspace');
}
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) {
return getWorkspaceCurrencyUpdateMessage(translate, parentReportAction);
Expand All @@ -414,7 +411,7 @@
return translate('systemMessage.mergedWithCashTransaction');
}
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) {
return Str.htmlDecode(getWorkspaceNameUpdatedMessage(parentReportAction));
return Str.htmlDecode(getWorkspaceNameUpdatedMessage(translate, parentReportAction));
}
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) {
return getWorkspaceFrequencyUpdateMessage(translate, parentReportAction);
Expand All @@ -430,7 +427,7 @@
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION)) {
return Parser.htmlToText(getUnreportedTransactionMessage(parentReportAction));
return Parser.htmlToText(getUnreportedTransactionMessage(translate, parentReportAction));
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) {
Expand All @@ -444,12 +441,10 @@
return getPolicyChangeLogDefaultReimbursableMessage(translate, parentReportAction);
}
if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return getPolicyChangeLogMaxExpenseAmountMessage(translateLocal, parentReportAction);
return getPolicyChangeLogMaxExpenseAmountMessage(translate, parentReportAction);
}
if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AGE)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return getPolicyChangeLogMaxExpenseAgeMessage(translateLocal, parentReportAction);
return getPolicyChangeLogMaxExpenseAgeMessage(translate, parentReportAction);
}
if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED)) {
return getPolicyChangeLogDefaultTitleEnforcedMessage(translate, parentReportAction);
Expand All @@ -461,12 +456,10 @@
return getUpdateACHAccountMessage(translate, parentReportAction);
}
if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_INVOICE_COMPANY_NAME)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return getInvoiceCompanyNameUpdateMessage(translateLocal, parentReportAction);
return getInvoiceCompanyNameUpdateMessage(translate, parentReportAction);
}
if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_INVOICE_COMPANY_WEBSITE)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return getInvoiceCompanyWebsiteUpdateMessage(translateLocal, parentReportAction);
return getInvoiceCompanyWebsiteUpdateMessage(translate, parentReportAction);
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT) && getOriginalMessage(parentReportAction)?.resolution) {
Expand All @@ -478,21 +471,19 @@
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY)) {
return getPolicyChangeMessage(parentReportAction);
return getPolicyChangeMessage(translate, parentReportAction);
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return Parser.htmlToText(getChangedApproverActionMessage(translateLocal, parentReportAction));
return Parser.htmlToText(getChangedApproverActionMessage(translate, parentReportAction));
}

if (parentReportAction?.actionName && isTagModificationAction(parentReportAction?.actionName)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return getCleanedTagName(getWorkspaceTagUpdateMessage(translateLocal, parentReportAction) ?? '');
return getCleanedTagName(getWorkspaceTagUpdateMessage(translate, parentReportAction) ?? '');
}

if (isMovedAction(parentReportAction)) {
return getMovedActionMessage(parentReportAction, parentReport);
return getMovedActionMessage(translate, parentReportAction, parentReport);
}

if (isMoneyRequestAction(parentReportAction)) {
Expand Down
Loading
Loading