Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show historical OldDot Report Actions in Plain text #38013

Merged
merged 11 commits into from
Mar 15, 2024
34 changes: 31 additions & 3 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,28 +573,57 @@ const CONST = {
SPLIT_REPORTID: '-2',
ACTIONS: {
LIMIT: 50,
// OldDot Actions render getMessage from Web-Expensify/lib/Report/Action PHP files via getMessageOfOldDotReportAction in ReportActionsUtils.ts
TYPE: {
ACTIONABLEMENTIONWHISPER: 'ACTIONABLEMENTIONWHISPER',
ADDCOMMENT: 'ADDCOMMENT',
ACTIONABLEJOINREQUEST: 'ACTIONABLEJOINREQUEST',
APPROVED: 'APPROVED',
CHANGEFIELD: 'CHANGEFIELD', // OldDot Action
CHANGEPOLICY: 'CHANGEPOLICY', // OldDot Action
CHANGETYPE: 'CHANGETYPE', // OldDot Action
CHRONOSOOOLIST: 'CHRONOSOOOLIST',
CLOSED: 'CLOSED',
CREATED: 'CREATED',
DELEGATESUBMIT: 'DELEGATESUBMIT', // OldDot Action
DELETEDACCOUNT: 'DELETEDACCOUNT', // OldDot Action
DONATION: 'DONATION', // OldDot Action
EXPORTEDTOCSV: 'EXPORTEDTOCSV', // OldDot Action
EXPORTEDTOINTEGRATION: 'EXPORTEDTOINTEGRATION', // OldDot Action
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed the value for this one is off. It should just be EXPORTINTEGRATION (src). @Beamanator can you update that? We're going to need it for the QBO doc I'm working on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @arosiclair ! fixed here: #42242

EXPORTEDTOQUICKBOOKS: 'EXPORTEDTOQUICKBOOKS', // OldDot Action
FORWARDED: 'FORWARDED', // OldDot Action
HOLD: 'HOLD',
IOU: 'IOU',
MARKEDREIMBURSED: 'MARKEDREIMBURSED',
INTEGRATIONSMESSAGE: 'INTEGRATIONSMESSAGE', // OldDot Action
MANAGERATTACHRECEIPT: 'MANAGERATTACHRECEIPT', // OldDot Action
MANAGERDETACHRECEIPT: 'MANAGERDETACHRECEIPT', // OldDot Action
MARKEDREIMBURSED: 'MARKEDREIMBURSED', // OldDot Action
MARKREIMBURSEDFROMINTEGRATION: 'MARKREIMBURSEDFROMINTEGRATION', // OldDot Action
MODIFIEDEXPENSE: 'MODIFIEDEXPENSE',
MOVED: 'MOVED',
OUTDATEDBANKACCOUNT: 'OUTDATEDBANKACCOUNT', // OldDot Action
REIMBURSEMENTACHBOUNCE: 'REIMBURSEMENTACHBOUNCE', // OldDot Action
REIMBURSEMENTACHCANCELLED: 'REIMBURSEMENTACHCANCELLED', // OldDot Action
REIMBURSEMENTACCOUNTCHANGED: 'REIMBURSEMENTACCOUNTCHANGED', // OldDot Action
REIMBURSEMENTDELAYED: 'REIMBURSEMENTDELAYED', // OldDot Action
REIMBURSEMENTQUEUED: 'REIMBURSEMENTQUEUED',
REIMBURSEMENTDEQUEUED: 'REIMBURSEMENTDEQUEUED',
REIMBURSEMENTREQUESTED: 'REIMBURSEMENTREQUESTED', // OldDot Action
REIMBURSEMENTSETUP: 'REIMBURSEMENTSETUP', // OldDot Action
RENAMED: 'RENAMED',
REPORTPREVIEW: 'REPORTPREVIEW',
SELECTEDFORRANDOMAUDIT: 'SELECTEDFORRANDOMAUDIT', // OldDot Action
SHARE: 'SHARE', // OldDot Action
STRIPEPAID: 'STRIPEPAID', // OldDot Action
SUBMITTED: 'SUBMITTED',
TAKECONTROL: 'TAKECONTROL', // OldDot Action
TASKCANCELLED: 'TASKCANCELLED',
TASKCOMPLETED: 'TASKCOMPLETED',
TASKEDITED: 'TASKEDITED',
TASKREOPENED: 'TASKREOPENED',
ACTIONABLEMENTIONWHISPER: 'ACTIONABLEMENTIONWHISPER',
UNAPPROVED: 'UNAPPROVED', // OldDot Action
UNHOLD: 'UNHOLD',
UNSHARE: 'UNSHARE', // OldDot Action
POLICYCHANGELOG: {
ADD_APPROVER_RULE: 'POLICYCHANGELOG_ADD_APPROVER_RULE',
ADD_BUDGET: 'POLICYCHANGELOG_ADD_BUDGET',
Expand Down Expand Up @@ -668,7 +697,6 @@ const CONST = {
LEAVE_ROOM: 'LEAVEROOM',
UPDATE_ROOM_DESCRIPTION: 'UPDATEROOMDESCRIPTION',
},
UNHOLD: 'UNHOLD',
},
THREAD_DISABLED: ['CREATED'],
},
Expand Down
43 changes: 43 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,47 @@ function getMemberChangeMessageFragment(reportAction: OnyxEntry<ReportAction>):
};
}

function isOldDotReportAction(action: ReportAction): boolean {
return [
CONST.REPORT.ACTIONS.TYPE.CHANGEFIELD,
CONST.REPORT.ACTIONS.TYPE.CHANGEPOLICY,
CONST.REPORT.ACTIONS.TYPE.CHANGETYPE,
CONST.REPORT.ACTIONS.TYPE.DELEGATESUBMIT,
CONST.REPORT.ACTIONS.TYPE.DELETEDACCOUNT,
CONST.REPORT.ACTIONS.TYPE.DONATION,
CONST.REPORT.ACTIONS.TYPE.EXPORTEDTOCSV,
CONST.REPORT.ACTIONS.TYPE.EXPORTEDTOINTEGRATION,
CONST.REPORT.ACTIONS.TYPE.EXPORTEDTOQUICKBOOKS,
CONST.REPORT.ACTIONS.TYPE.FORWARDED,
CONST.REPORT.ACTIONS.TYPE.INTEGRATIONSMESSAGE,
CONST.REPORT.ACTIONS.TYPE.MANAGERATTACHRECEIPT,
CONST.REPORT.ACTIONS.TYPE.MANAGERDETACHRECEIPT,
CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED,
CONST.REPORT.ACTIONS.TYPE.MARKREIMBURSEDFROMINTEGRATION,
CONST.REPORT.ACTIONS.TYPE.OUTDATEDBANKACCOUNT,
CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTACHBOUNCE,
CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTACHCANCELLED,
CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTACCOUNTCHANGED,
CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDELAYED,
CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTREQUESTED,
CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTSETUP,
CONST.REPORT.ACTIONS.TYPE.SELECTEDFORRANDOMAUDIT,
CONST.REPORT.ACTIONS.TYPE.SHARE,
CONST.REPORT.ACTIONS.TYPE.STRIPEPAID,
CONST.REPORT.ACTIONS.TYPE.TAKECONTROL,
CONST.REPORT.ACTIONS.TYPE.UNAPPROVED,
CONST.REPORT.ACTIONS.TYPE.UNSHARE,
].some((oldDotActionName) => oldDotActionName === action.actionName);
}

/**
* 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<ReportAction>): string {
return reportAction?.message?.map((element) => element.text).join('') ?? '';
}

function getMemberChangeMessagePlainText(reportAction: OnyxEntry<ReportAction>): string {
const messageElements = getMemberChangeMessageElements(reportAction);
return messageElements.map((element) => element.content).join('');
Expand Down Expand Up @@ -969,6 +1010,8 @@ export {
getFirstVisibleReportActionID,
isMemberChangeAction,
getMemberChangeMessageFragment,
isOldDotReportAction,
getMessageOfOldDotReportAction,
getMemberChangeMessagePlainText,
isReimbursementDeQueuedAction,
isActionableMentionWhisper,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={ReportUtils.getReimbursementDeQueuedActionMessage(action, report)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) {
children = <ReportActionItemBasicMessage message={ModifiedExpenseMessage.getForReportAction(report.reportID, action)} />;
} else if (ReportActionsUtils.isOldDotReportAction(action)) {
// This handles all historical actions from OldDot that we just want to display the message text
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getMessageOfOldDotReportAction(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.heldRequest', {comment: action.message?.[1].text ?? ''})} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
Expand Down
Loading