diff --git a/src/CONST.ts b/src/CONST.ts index 233b35e6ac4bd..d5502841c7d17 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -674,12 +674,12 @@ const CONST = { CLOSED: 'CLOSED', CREATED: 'CREATED', DELEGATE_SUBMIT: 'DELEGATESUBMIT', // OldDot Action - DELETED_ACCOUNT: 'DELETEDACCOUNT', // OldDot Action + DELETED_ACCOUNT: 'DELETEDACCOUNT', // Deprecated OldDot Action DISMISSED_VIOLATION: 'DISMISSEDVIOLATION', - DONATION: 'DONATION', // OldDot Action + DONATION: 'DONATION', // Deprecated OldDot Action EXPORTED_TO_CSV: 'EXPORTCSV', // OldDot Action EXPORTED_TO_INTEGRATION: 'EXPORTINTEGRATION', // OldDot Action - EXPORTED_TO_QUICK_BOOKS: 'EXPORTED', // OldDot Action + EXPORTED_TO_QUICK_BOOKS: 'EXPORTED', // Deprecated OldDot Action FORWARDED: 'FORWARDED', // OldDot Action HOLD: 'HOLD', HOLD_COMMENT: 'HOLDCOMMENT', @@ -699,9 +699,9 @@ const CONST = { REIMBURSEMENT_DELAYED: 'REIMBURSEMENTDELAYED', // OldDot Action REIMBURSEMENT_QUEUED: 'REIMBURSEMENTQUEUED', REIMBURSEMENT_DEQUEUED: 'REIMBURSEMENTDEQUEUED', - REIMBURSEMENT_REQUESTED: 'REIMBURSEMENTREQUESTED', // OldDot Action - REIMBURSEMENT_SETUP: 'REIMBURSEMENTSETUP', // OldDot Action - REIMBURSEMENT_SETUP_REQUESTED: 'REIMBURSEMENTSETUPREQUESTED', // OldDot Action + REIMBURSEMENT_REQUESTED: 'REIMBURSEMENTREQUESTED', // Deprecated OldDot Action + REIMBURSEMENT_SETUP: 'REIMBURSEMENTSETUP', // Deprecated OldDot Action + REIMBURSEMENT_SETUP_REQUESTED: 'REIMBURSEMENTSETUPREQUESTED', // Deprecated OldDot Action RENAMED: 'RENAMED', REPORT_PREVIEW: 'REPORTPREVIEW', SELECTED_FOR_RANDOM_AUDIT: 'SELECTEDFORRANDOMAUDIT', // OldDot Action diff --git a/src/languages/en.ts b/src/languages/en.ts index 095cc12a38961..f35b12626148c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -12,10 +12,14 @@ import type { BeginningOfChatHistoryAnnounceRoomPartTwo, BeginningOfChatHistoryDomainRoomPartOneParams, CanceledRequestParams, + ChangeFieldParams, + ChangePolicyParams, + ChangeTypeParams, CharacterLimitParams, ConfirmThatParams, DateShouldBeAfterParams, DateShouldBeBeforeParams, + DelegateSubmitParams, DeleteActionParams, DeleteConfirmationParams, DidSplitAmountMessageParams, @@ -23,15 +27,20 @@ import type { EditActionParams, ElectronicFundsParams, EnterMagicCodeParams, + ExportedToIntegrationParams, FormattedMaxLengthParams, + ForwardedParams, GoBackMessageParams, GoToRoomParams, InstantSummaryParams, + IntegrationsMessageParams, LocalTimeParams, LoggedInAsParams, LogSizeParams, ManagerApprovedAmountParams, ManagerApprovedParams, + MarkedReimbursedParams, + MarkReimbursedFromIntegrationParams, NoLongerHaveAccessParams, NotAllowedExtensionParams, NotYouParams, @@ -65,10 +74,12 @@ import type { SetTheRequestParams, SettledAfterAddedBankAccountParams, SettleExpensifyCardParams, + ShareParams, SignUpNewFaceCodeParams, SizeExceededParams, SplitAmountParams, StepCounterParams, + StripePaidParams, TaskCreatedActionParams, TermsParams, ThreadRequestReportNameParams, @@ -76,6 +87,8 @@ import type { ToValidateLoginParams, TransferParams, TranslationBase, + UnapprovedParams, + UnshareParams, UntilTimeParams, UpdatedTheDistanceParams, UpdatedTheRequestParams, @@ -3022,6 +3035,34 @@ export default { genericUpdateReportFieldFailureMessage: 'Unexpected error updating the field. Please try again later.', genericUpdateReporNameEditFailureMessage: 'Unexpected error renaming the report. Please try again later.', noActivityYet: 'No activity yet', + actions: { + type: { + changeField: ({oldValue, newValue, fieldName}: ChangeFieldParams) => `changed ${fieldName} from ${oldValue} to ${newValue}`, + changeFieldEmpty: ({newValue, fieldName}: ChangeFieldParams) => `changed ${fieldName} to ${newValue}`, + changePolicy: ({fromPolicy, toPolicy}: ChangePolicyParams) => `changed policy from ${fromPolicy} to ${toPolicy}`, + changeType: ({oldType, newType}: ChangeTypeParams) => `changed type from ${oldType} to ${newType}`, + delegateSubmit: ({delegateUser, originalManager}: DelegateSubmitParams) => `sent this report to ${delegateUser} since ${originalManager} is on vacation`, + exportedToCSV: `exported this report to CSV`, + exportedToIntegration: ({label}: ExportedToIntegrationParams) => `exported this report to ${label}`, + forwarded: ({amount, currency}: ForwardedParams) => `approved ${currency}${amount}`, + integrationsMessage: ({errorMessage, label}: IntegrationsMessageParams) => `failed to export this report to ${label}. ${errorMessage}`, + managerAttachReceipt: `added a receipt`, + managerDetachReceipt: `removed the receipt`, + markedReimbursed: ({amount, currency}: MarkedReimbursedParams) => `paid ${currency}${amount} elsewhere`, + markedReimbursedFromIntegration: ({amount, currency}: MarkReimbursedFromIntegrationParams) => `paid ${currency}${amount} via integration`, + outdatedBankAccount: `couldn’t process the payment due to a problem with the payer’s bank account`, + reimbursementACHBounce: `couldn’t process the payment, as the payer doesn’t have sufficient funds`, + reimbursementACHCancelled: `canceled the payment`, + reimbursementAccountChanged: `couldn’t process the payment, as the payer changed bank accounts`, + reimbursementDelayed: `processed the payment but it’s delayed by 1-2 more business days`, + selectedForRandomAudit: `[randomly selected](https://help.expensify.com/articles/expensify-classic/reports/Set-a-random-report-audit-schedule) for review`, + share: ({to}: ShareParams) => `invited user ${to}`, + unshare: ({to}: UnshareParams) => `removed user ${to}`, + stripePaid: ({amount, currency}: StripePaidParams) => `paid ${currency}${amount}`, + takeControl: `took control`, + unapproved: ({amount, currency}: UnapprovedParams) => `unapproved ${currency}${amount}`, + }, + }, }, chronos: { oooEventSummaryFullDay: ({summary, dayCount, date}: OOOEventSummaryFullDayParams) => `${summary} for ${dayCount} ${dayCount === 1 ? 'day' : 'days'} until ${date}`, diff --git a/src/languages/es.ts b/src/languages/es.ts index e2a00222c62a5..e12c766a7e218 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -11,10 +11,14 @@ import type { BeginningOfChatHistoryAnnounceRoomPartTwo, BeginningOfChatHistoryDomainRoomPartOneParams, CanceledRequestParams, + ChangeFieldParams, + ChangePolicyParams, + ChangeTypeParams, CharacterLimitParams, ConfirmThatParams, DateShouldBeAfterParams, DateShouldBeBeforeParams, + DelegateSubmitParams, DeleteActionParams, DeleteConfirmationParams, DidSplitAmountMessageParams, @@ -23,15 +27,20 @@ import type { ElectronicFundsParams, EnglishTranslation, EnterMagicCodeParams, + ExportedToIntegrationParams, FormattedMaxLengthParams, + ForwardedParams, GoBackMessageParams, GoToRoomParams, InstantSummaryParams, + IntegrationsMessageParams, LocalTimeParams, LoggedInAsParams, LogSizeParams, ManagerApprovedAmountParams, ManagerApprovedParams, + MarkedReimbursedParams, + MarkReimbursedFromIntegrationParams, NoLongerHaveAccessParams, NotAllowedExtensionParams, NotYouParams, @@ -65,16 +74,20 @@ import type { SetTheRequestParams, SettledAfterAddedBankAccountParams, SettleExpensifyCardParams, + ShareParams, SignUpNewFaceCodeParams, SizeExceededParams, SplitAmountParams, StepCounterParams, + StripePaidParams, TaskCreatedActionParams, TermsParams, ThreadRequestReportNameParams, ThreadSentMoneyReportNameParams, ToValidateLoginParams, TransferParams, + UnapprovedParams, + UnshareParams, UntilTimeParams, UpdatedTheDistanceParams, UpdatedTheRequestParams, @@ -3058,6 +3071,34 @@ export default { genericUpdateReportFieldFailureMessage: 'Error inesperado al actualizar el campo. Por favor, inténtalo más tarde.', genericUpdateReporNameEditFailureMessage: 'Error inesperado al cambiar el nombre del informe. Por favor, intentarlo más tarde.', noActivityYet: 'Sin actividad todavía', + actions: { + type: { + changeField: ({oldValue, newValue, fieldName}: ChangeFieldParams) => `cambió ${fieldName} de ${oldValue} a ${newValue}`, + changeFieldEmpty: ({newValue, fieldName}: ChangeFieldParams) => `cambió ${fieldName} a ${newValue}`, + changePolicy: ({fromPolicy, toPolicy}: ChangePolicyParams) => `cambió policy de ${fromPolicy} a ${toPolicy}`, + changeType: ({oldType, newType}: ChangeTypeParams) => `cambió type de ${oldType} a ${newType}`, + delegateSubmit: ({delegateUser, originalManager}: DelegateSubmitParams) => `envié este informe a ${delegateUser} ya que ${originalManager} está de vacaciones`, + exportedToCSV: `exportó este informe a CSV`, + exportedToIntegration: ({label}: ExportedToIntegrationParams) => `exportó este informe a ${label}`, + forwarded: ({amount, currency}: ForwardedParams) => `aprobado ${currency}${amount}`, + integrationsMessage: ({errorMessage, label}: IntegrationsMessageParams) => `no se pudo exportar este informe a ${label}. ${errorMessage}`, + managerAttachReceipt: `agregó un recibo`, + managerDetachReceipt: `quitó el recibo`, + markedReimbursed: ({amount, currency}: MarkedReimbursedParams) => `pagó ${currency}${amount} en otro lugar`, + markedReimbursedFromIntegration: ({amount, currency}: MarkReimbursedFromIntegrationParams) => `pagó ${currency}${amount} mediante integración`, + outdatedBankAccount: `no se pudo procesar el pago debido a un problema con la cuenta bancaria del pagador`, + reimbursementACHBounce: `no se pudo procesar el pago porque el pagador no tiene fondos suficientes`, + reimbursementACHCancelled: `canceled the payment`, + reimbursementAccountChanged: `no se pudo procesar el pago porque el pagador cambió de cuenta bancaria`, + reimbursementDelayed: `procesó el pago pero se retrasó entre 1 y 2 días hábiles más`, + selectedForRandomAudit: `[seleccionado al azar](https://help.expensify.com/articles/expensify-classic/reports/Set-a-random-report-audit-schedule) para revisión`, + share: ({to}: ShareParams) => `usuario invitado ${to}`, + unshare: ({to}: UnshareParams) => `usuario eliminado ${to}`, + stripePaid: ({amount, currency}: StripePaidParams) => `pagado ${currency}${amount}`, + takeControl: `tomó el control`, + unapproved: ({amount, currency}: UnapprovedParams) => `no aprobado ${currency}${amount}`, + }, + }, }, chronos: { oooEventSummaryFullDay: ({summary, dayCount, date}: OOOEventSummaryFullDayParams) => `${summary} por ${dayCount} ${dayCount === 1 ? 'día' : 'días'} hasta el ${date}`, diff --git a/src/languages/types.ts b/src/languages/types.ts index c38fb4aadae57..eb90f2d9e0b21 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -298,6 +298,31 @@ type DistanceRateOperationsParams = {count: number}; type ReimbursementRateParams = {unit: Unit}; +type ChangeFieldParams = {oldValue?: string; newValue: string; fieldName: string}; + +type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; + +type ChangeTypeParams = {oldType: string; newType: string}; + +type DelegateSubmitParams = {delegateUser: string; originalManager: string}; + +type ExportedToIntegrationParams = {label: string}; + +type ForwardedParams = {amount: string; currency: string}; + +type IntegrationsMessageParams = {errorMessage: string; label: string}; + +type MarkedReimbursedParams = {amount: string; currency: string}; + +type MarkReimbursedFromIntegrationParams = {amount: string; currency: string}; + +type ShareParams = {to: string}; + +type UnshareParams = {to: string}; + +type StripePaidParams = {amount: string; currency: string}; + +type UnapprovedParams = {amount: string; currency: string}; type RemoveMembersWarningPrompt = { memberName: string; ownerName: string; @@ -407,5 +432,18 @@ export type { WelcomeNoteParams, WelcomeToRoomParams, ZipCodeExampleFormatParams, + ChangeFieldParams, + ChangePolicyParams, + ChangeTypeParams, + ExportedToIntegrationParams, + DelegateSubmitParams, + ForwardedParams, + IntegrationsMessageParams, + MarkedReimbursedParams, + MarkReimbursedFromIntegrationParams, + ShareParams, + UnshareParams, + StripePaidParams, + UnapprovedParams, RemoveMembersWarningPrompt, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 83dfeaa08fa0e..c8599d785b22f 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -10,7 +10,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {OnyxInputOrEntry} from '@src/types/onyx'; import type {JoinWorkspaceResolution} from '@src/types/onyx/OriginalMessage'; import type Report from '@src/types/onyx/Report'; -import type {Message, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction'; +import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction'; import type ReportAction from '@src/types/onyx/ReportAction'; import type ReportActionName from '@src/types/onyx/ReportActionName'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -1171,17 +1171,24 @@ function getMemberChangeMessageFragment(reportAction: OnyxEntry): }; } -function isOldDotReportAction(action: ReportAction): boolean { +function isOldDotLegacyAction(action: OldDotReportAction | PartialReportAction): action is PartialReportAction { + return [ + CONST.REPORT.ACTIONS.TYPE.DELETED_ACCOUNT, + CONST.REPORT.ACTIONS.TYPE.DONATION, + CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_QUICK_BOOKS, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP, + ].some((oldDotActionName) => oldDotActionName === action?.actionName); +} + +function isOldDotReportAction(action: ReportAction | OldDotReportAction) { return [ CONST.REPORT.ACTIONS.TYPE.CHANGE_FIELD, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY, CONST.REPORT.ACTIONS.TYPE.CHANGE_TYPE, CONST.REPORT.ACTIONS.TYPE.DELEGATE_SUBMIT, - CONST.REPORT.ACTIONS.TYPE.DELETED_ACCOUNT, - CONST.REPORT.ACTIONS.TYPE.DONATION, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_CSV, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION, - CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_QUICK_BOOKS, CONST.REPORT.ACTIONS.TYPE.FORWARDED, CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE, CONST.REPORT.ACTIONS.TYPE.MANAGER_ATTACH_RECEIPT, @@ -1193,28 +1200,94 @@ function isOldDotReportAction(action: ReportAction): boolean { CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_CANCELLED, CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACCOUNT_CHANGED, CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DELAYED, - CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED, - CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP, CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT, CONST.REPORT.ACTIONS.TYPE.SHARE, CONST.REPORT.ACTIONS.TYPE.STRIPE_PAID, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL, CONST.REPORT.ACTIONS.TYPE.UNAPPROVED, CONST.REPORT.ACTIONS.TYPE.UNSHARE, + CONST.REPORT.ACTIONS.TYPE.DELETED_ACCOUNT, + CONST.REPORT.ACTIONS.TYPE.DONATION, + CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_QUICK_BOOKS, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP, ].some((oldDotActionName) => oldDotActionName === action.actionName); } +function getMessageOfOldDotLegacyAction(legacyAction: PartialReportAction) { + if (!Array.isArray(legacyAction?.message)) { + return getReportActionText(legacyAction); + } + if (legacyAction.message.length !== 0) { + // Sometime html can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + return legacyAction?.message?.map((element) => getTextFromHtml(element?.html || element?.text)).join('') ?? ''; + } + return ''; +} + /** * Helper method to format message of OldDot Actions. - * For now, we just concat all of the text elements of the message to create the full message. */ -function getMessageOfOldDotReportAction(reportAction: OnyxEntry): string { - if (!Array.isArray(reportAction?.message)) { - return getReportActionText(reportAction); +function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldDotReportAction): string { + if (isOldDotLegacyAction(oldDotAction)) { + return getMessageOfOldDotLegacyAction(oldDotAction); + } + + const {originalMessage, actionName} = oldDotAction; + switch (actionName) { + case CONST.REPORT.ACTIONS.TYPE.CHANGE_FIELD: { + const {oldValue, newValue, fieldName} = originalMessage; + if (!oldValue) { + Localize.translateLocal('report.actions.type.changeFieldEmpty', {newValue, fieldName}); + } + return Localize.translateLocal('report.actions.type.changeField', {oldValue, newValue, fieldName}); + } + case CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY: { + const {fromPolicy, toPolicy} = originalMessage; + return Localize.translateLocal('report.actions.type.changePolicy', {fromPolicy, toPolicy}); + } + case CONST.REPORT.ACTIONS.TYPE.DELEGATE_SUBMIT: { + const {delegateUser, originalManager} = originalMessage; + return Localize.translateLocal('report.actions.type.delegateSubmit', {delegateUser, originalManager}); + } + case CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_CSV: + return Localize.translateLocal('report.actions.type.exportedToCSV'); + case CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION: + return Localize.translateLocal('report.actions.type.exportedToIntegration', {label: originalMessage.label}); + case CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE: { + const {errorMessage, label} = originalMessage; + return Localize.translateLocal('report.actions.type.integrationsMessage', {errorMessage, label}); + } + case CONST.REPORT.ACTIONS.TYPE.MANAGER_ATTACH_RECEIPT: + return Localize.translateLocal('report.actions.type.managerAttachReceipt'); + case CONST.REPORT.ACTIONS.TYPE.MANAGER_DETACH_RECEIPT: + return Localize.translateLocal('report.actions.type.managerDetachReceipt'); + case CONST.REPORT.ACTIONS.TYPE.MARK_REIMBURSED_FROM_INTEGRATION: { + const {amount, currency} = originalMessage; + return Localize.translateLocal('report.actions.type.markedReimbursedFromIntegration', {amount, currency}); + } + case CONST.REPORT.ACTIONS.TYPE.OUTDATED_BANK_ACCOUNT: + return Localize.translateLocal('report.actions.type.outdatedBankAccount'); + case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_BOUNCE: + return Localize.translateLocal('report.actions.type.reimbursementACHBounce'); + case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_CANCELLED: + return Localize.translateLocal('report.actions.type.reimbursementACHCancelled'); + case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACCOUNT_CHANGED: + return Localize.translateLocal('report.actions.type.reimbursementAccountChanged'); + case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DELAYED: + return Localize.translateLocal('report.actions.type.reimbursementDelayed'); + case CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT: + return Localize.translateLocal('report.actions.type.selectedForRandomAudit'); + case CONST.REPORT.ACTIONS.TYPE.SHARE: + return Localize.translateLocal('report.actions.type.share', {to: originalMessage.to}); + case CONST.REPORT.ACTIONS.TYPE.UNSHARE: + return Localize.translateLocal('report.actions.type.unshare', {to: originalMessage.to}); + case CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL: + return Localize.translateLocal('report.actions.type.takeControl'); + default: + return ''; } - // Sometime html can be an empty string - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - return reportAction?.message?.map((element) => getTextFromHtml(element?.html || element?.text)).join('') ?? ''; } function getMemberChangeMessagePlainText(reportAction: OnyxEntry): string { diff --git a/src/types/onyx/OldDotAction.ts b/src/types/onyx/OldDotAction.ts new file mode 100644 index 0000000000000..66827eae4b6b7 --- /dev/null +++ b/src/types/onyx/OldDotAction.ts @@ -0,0 +1,484 @@ +import type {ValueOf} from 'type-fest'; +import type CONST from '@src/CONST'; +import type { + ChangeFieldParams, + ChangePolicyParams, + DelegateSubmitParams, + ExportedToIntegrationParams, + IntegrationsMessageParams, + MarkReimbursedFromIntegrationParams, + ShareParams, + UnshareParams, +} from '@src/languages/types'; + +/** + * + */ +type OldDotOriginalMessageActionName = + | 'CHANGEFIELD' + | 'CHANGEPOLICY' + | 'CHANGETYPE' + | 'DELEGATESUBMIT' + | 'EXPORTCSV' + | 'EXPORTINTEGRATION' + | 'FORWARDED' + | 'INTEGRATIONSMESSAGE' + | 'MANAGERATTACHRECEIPT' + | 'MANAGERDETACHRECEIPT' + | 'MARKEDREIMBURSED' + | 'MARKREIMBURSEDFROMINTEGRATION' + | 'OUTDATEDBANKACCOUNT' + | 'REIMBURSEMENTACHBOUNCE' + | 'REIMBURSEMENTACHCANCELLED' + | 'REIMBURSEMENTACCOUNTCHANGED' + | 'REIMBURSEMENTDELAYED' + | 'SELECTEDFORRANDOMAUDIT' + | 'SHARE' + | 'STRIPEPAID' + | 'TAKECONTROL' + | 'UNAPPROVED' + | 'UNSHARE'; + +/** + * + */ +type OriginalMessageChangeField = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHANGE_FIELD; + /** + * + */ + originalMessage: Record & ChangeFieldParams; +}; + +/** + * + */ +type OriginalMessageChangePolicy = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY; + /** + * + */ + originalMessage: ChangePolicyParams & Record; +}; + +// Currently lacking Params +// type OriginalMessageChangeType = { +// /** +// * +// */ +// actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHANGE_TYPE; +// /** +// * +// */ +// originalMessage: ChangeTypeParams & Record; +// }; + +/** + * + */ +type OriginalMessageDelegateSubmit = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.DELEGATE_SUBMIT; + /** + * + */ + originalMessage: DelegateSubmitParams & Record; +}; + +/** + * + */ +type OriginalMessageExportedToCSV = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_CSV; + /** + * + */ + originalMessage: Record; +}; + +/** + * + */ +type OriginalMessageExportedToIntegration = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION; + /** + * + */ + originalMessage: ExportedToIntegrationParams & Record; +}; + +// Currently lacking Params +// type OriginalMessagePolicyTask = { +// /** +// * +// */ +// actionName: typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED; +// /** +// * +// */ +// originalMessage: ForwardedParams & Record; +// }; + +/** + * + */ +type OriginalMessageIntegrationsMessage = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE; + /** + * + */ + originalMessage: IntegrationsMessageParams & Record; +}; + +/** + * + */ +type OriginalMessageManagerAttachReceipt = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.MANAGER_ATTACH_RECEIPT; + /** + * + */ + originalMessage: Record; +}; + +/** + * + */ +type OriginalMessageManagerDetachReceipt = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.MANAGER_DETACH_RECEIPT; + /** + * + */ + originalMessage: Record; +}; + +// Currently lacking Params +// type OriginalMessageMarkedReimbursed = { +// /** +// * +// */ +// actionName: typeof CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED; +// /** +// * +// */ +// originalMessage: MarkedReimbursedParams & Record; +// }; + +/** + * + */ +type OriginalMessageMarkReimbursedFromIntegration = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.MARK_REIMBURSED_FROM_INTEGRATION; + /** + * + */ + originalMessage: MarkReimbursedFromIntegrationParams & Record; +}; + +/** + * + */ +type OriginalMessageOutdatedBankAccount = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.OUTDATED_BANK_ACCOUNT; + /** + * + */ + originalMessage: Record; +}; + +/** + * + */ +type OriginalMessageReimbursementACHBounce = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_BOUNCE; + /** + * + */ + originalMessage: Record; +}; + +/** + * + */ +type OriginalMessageReimbursementACHCancelled = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_CANCELLED; + /** + * + */ + originalMessage: Record; +}; + +/** + * + */ +type OriginalMessageReimbursementAccountChanged = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACCOUNT_CHANGED; + /** + * + */ + originalMessage: Record; +}; + +/** + * + */ +type OriginalMessageReimbursementDelayed = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DELAYED; + /** + * + */ + originalMessage: Record; +}; + +/** + * + */ +type OriginalMessageSelectedForRandomAudit = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT; + /** + * + */ + originalMessage: Record; +}; + +/** + * + */ +type OriginalMessageShare = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.SHARE; + /** + * + */ + originalMessage: ShareParams & Record; +}; + +/** + * + */ +type OriginalMessageUnshare = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.UNSHARE; + /** + * + */ + originalMessage: UnshareParams & Record; +}; + +// Currently lacking Params +// type OriginalMessageStripePaid = { +// /** +// * +// */ +// actionName: typeof CONST.REPORT.ACTIONS.TYPE.STRIPE_PAID; +// /** +// * +// */ +// originalMessage: StripePaidParams & Record; +// }; + +/** + * + */ +type OriginalMessageTakeControl = { + /** + * + */ + actionName: typeof CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL; + /** + * + */ + originalMessage: Record; +}; + +// Currently lacking Params +// type OriginalMessageUnapproved = { +// /** +// * +// */ +// actionName: typeof CONST.REPORT.ACTIONS.TYPE.UNAPPROVED; +// /** +// * +// */ +// originalMessage: UnapprovedParams & Record; +// }; + +/** + * + */ +type OldDotOriginalMessageMap = { + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.CHANGE_FIELD]: OriginalMessageChangeField; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY]: OriginalMessageChangePolicy; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.DELEGATE_SUBMIT]: OriginalMessageDelegateSubmit; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_CSV]: OriginalMessageExportedToCSV; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION]: OriginalMessageExportedToIntegration; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE]: OriginalMessageIntegrationsMessage; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.MANAGER_ATTACH_RECEIPT]: OriginalMessageManagerAttachReceipt; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.MANAGER_DETACH_RECEIPT]: OriginalMessageManagerDetachReceipt; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.MARK_REIMBURSED_FROM_INTEGRATION]: OriginalMessageMarkReimbursedFromIntegration; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.OUTDATED_BANK_ACCOUNT]: OriginalMessageOutdatedBankAccount; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_BOUNCE]: OriginalMessageReimbursementACHBounce; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_CANCELLED]: OriginalMessageReimbursementACHCancelled; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACCOUNT_CHANGED]: OriginalMessageReimbursementAccountChanged; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DELAYED]: OriginalMessageReimbursementDelayed; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT]: OriginalMessageSelectedForRandomAudit; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.SHARE]: OriginalMessageShare; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.UNSHARE]: OriginalMessageUnshare; + /** + * + */ + [CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL]: OriginalMessageTakeControl; +}; + +/** + * + */ +type OldDotLegacyMessage = { + /** + * + */ + html?: string; + /** + * + */ + text?: string; +}; + +/** + * + */ +type OldDotLegacyAction = { + /** + * + */ + message: OldDotLegacyMessage[] | OldDotLegacyMessage; +}; + +/** + * + */ +type OldDotAction = ValueOf; + +export default OldDotAction; +export type { + OriginalMessageChangeField, + OldDotOriginalMessageActionName, + OriginalMessageChangePolicy, + OriginalMessageDelegateSubmit, + OriginalMessageExportedToCSV, + OriginalMessageExportedToIntegration, + OriginalMessageIntegrationsMessage, + OriginalMessageManagerAttachReceipt, + OriginalMessageManagerDetachReceipt, + OriginalMessageMarkReimbursedFromIntegration, + OriginalMessageOutdatedBankAccount, + OriginalMessageReimbursementACHBounce, + OriginalMessageReimbursementACHCancelled, + OriginalMessageReimbursementAccountChanged, + OriginalMessageReimbursementDelayed, + OriginalMessageSelectedForRandomAudit, + OriginalMessageShare, + OriginalMessageUnshare, + OriginalMessageTakeControl, + OldDotOriginalMessageMap, + OldDotLegacyAction, +}; diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index edeeeab551b09..c7d9397f3202b 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -1,7 +1,7 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; -import type AssertTypesEqual from '@src/types/utils/AssertTypesEqual'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; +import type {OldDotOriginalMessageMap} from './OldDotAction'; import type ReportActionName from './ReportActionName'; /** Types of join workspace resolutions */ @@ -431,18 +431,12 @@ type OriginalMessageMap = { /** */ [CONST.REPORT.ACTIONS.TYPE.DELEGATE_SUBMIT]: never; /** */ - [CONST.REPORT.ACTIONS.TYPE.DELETED_ACCOUNT]: never; - /** */ [CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION]: OriginalMessageDismissedViolation; /** */ - [CONST.REPORT.ACTIONS.TYPE.DONATION]: never; - /** */ [CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_CSV]: never; /** */ [CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION]: never; /** */ - [CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_QUICK_BOOKS]: never; - /** */ [CONST.REPORT.ACTIONS.TYPE.FORWARDED]: never; /** */ [CONST.REPORT.ACTIONS.TYPE.HOLD]: never; @@ -481,10 +475,6 @@ type OriginalMessageMap = { /** */ [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED]: OriginalMessageReimbursementQueued; /** */ - [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED]: never; - /** */ - [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP]: never; - /** */ [CONST.REPORT.ACTIONS.TYPE.RENAMED]: OriginalMessageRenamed; /** */ [CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW]: OriginalMessageReportPreview; @@ -515,22 +505,28 @@ type OriginalMessageMap = { /** */ [CONST.REPORT.ACTIONS.TYPE.UPDATE_GROUP_CHAT_MEMBER_ROLE]: never; /** */ - [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP_REQUESTED]: never; - /** */ [CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW]: OriginalMessageTripRoomPreview; -} & { - [T in ValueOf]: OriginalMessageChangeLog; -} & { - [T in ValueOf]: OriginalMessageChangeLog; -}; - -/** */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -type AssertOriginalMessageDefinedForAllActions = AssertTypesEqual< - ReportActionName, - keyof OriginalMessageMap, - `Error: Types don't match, OriginalMessageMap type is missing: ${Exclude}` ->; + /** */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED]: never; + /** */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP]: never; + /** */ + [CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_QUICK_BOOKS]: never; + /** */ + [CONST.REPORT.ACTIONS.TYPE.DONATION]: never; + /** */ + [CONST.REPORT.ACTIONS.TYPE.DELETED_ACCOUNT]: never; + /** */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED]: never; + /** */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP]: never; + /** */ + [CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP_REQUESTED]: never; +} & OldDotOriginalMessageMap & { + [T in ValueOf]: OriginalMessageChangeLog; + } & { + [T in ValueOf]: OriginalMessageChangeLog; + }; /** */ type OriginalMessage = OriginalMessageMap[T]; diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index b7624539a86bc..d43151fe1d9cf 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -4,6 +4,7 @@ import type {AvatarSource} from '@libs/UserUtils'; import type CONST from '@src/CONST'; import type ONYXKEYS from '@src/ONYXKEYS'; import type CollectionDataSet from '@src/types/utils/CollectionDataSet'; +import type OldDotAction from './OldDotAction'; import type * as OnyxCommon from './OnyxCommon'; import type OriginalMessage from './OriginalMessage'; import type {Decision} from './OriginalMessage'; @@ -265,6 +266,11 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ whisperedToAccountIDs?: number[]; }>; +/** + * + */ +type OldDotReportAction = ReportActionBase & OldDotAction; + /** * */ @@ -289,4 +295,4 @@ type ReportActions = Record; type ReportActionsCollectionDataSet = CollectionDataSet; export default ReportAction; -export type {ReportActions, Message, LinkMetadata, OriginalMessage, ReportActionsCollectionDataSet, ReportActionChangeLog}; +export type {ReportActions, Message, LinkMetadata, OriginalMessage, ReportActionsCollectionDataSet, ReportActionChangeLog, OldDotReportAction}; diff --git a/tests/utils/collections/reportActions.ts b/tests/utils/collections/reportActions.ts index 67dfdc10f00e8..4836120a405bc 100644 --- a/tests/utils/collections/reportActions.ts +++ b/tests/utils/collections/reportActions.ts @@ -31,7 +31,7 @@ const deprecatedReportActions: ReportActionName[] = [ CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED, CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP_REQUESTED, CONST.REPORT.ACTIONS.TYPE.DONATION, -]; +] as const; export default function createRandomReportAction(index: number): ReportAction { return {