Skip to content

Commit

Permalink
Merge pull request #38013 from eh2077/37022-showHistoricalOldDotActions
Browse files Browse the repository at this point in the history
Show historical OldDot Report Actions in Plain text
  • Loading branch information
Beamanator authored Mar 15, 2024
2 parents 2abedcd + ea29ad9 commit e9c112a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,28 +575,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
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 @@ -670,7 +699,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 @@ -513,6 +513,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

0 comments on commit e9c112a

Please sign in to comment.