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
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3686,7 +3686,8 @@ export default {
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`,
selectedForRandomAudit: `randomly selected for review`,
selectedForRandomAuditMarkdown: `[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}`,
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3743,7 +3743,8 @@ export default {
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`,
selectedForRandomAudit: `seleccionado al azar para revisión`,
selectedForRandomAuditMarkdown: `[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}`,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
} else if (lastReportAction?.actionName === 'EXPORTINTEGRATION') {
lastMessageTextFromReport = ReportActionUtils.getExportIntegrationLastMessageText(lastReportAction);
} else if (lastReportAction?.actionName && ReportActionUtils.isOldDotReportAction(lastReportAction)) {
lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction);
lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction, false);
}

return lastMessageTextFromReport || (report?.lastMessageText ?? '');
Expand Down
63 changes: 39 additions & 24 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,28 +1143,6 @@ function getTextFromHtml(html?: string): string {
return html ? Parser.htmlToText(html) : '';
}

function getMemberChangeMessageFragment(reportAction: OnyxEntry<ReportAction>): Message {
const messageElements: readonly MemberChangeMessageElement[] = getMemberChangeMessageElements(reportAction);
const html = messageElements
.map((messageElement) => {
switch (messageElement.kind) {
case 'userMention':
return `<mention-user accountID=${messageElement.accountID}>${messageElement.content}</mention-user>`;
case 'roomReference':
return `<a href="${environmentURL}/r/${messageElement.roomID}" target="_blank">${messageElement.roomName}</a>`;
default:
return messageElement.content;
}
})
.join('');

return {
html: `<muted-text>${html}</muted-text>`,
text: getReportActionMessage(reportAction) ? getReportActionText(reportAction) : '',
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
};
}

function isOldDotLegacyAction(action: OldDotReportAction | PartialReportAction): action is PartialReportAction {
return [
CONST.REPORT.ACTIONS.TYPE.DELETED_ACCOUNT,
Expand Down Expand Up @@ -1221,7 +1199,7 @@ function getMessageOfOldDotLegacyAction(legacyAction: PartialReportAction) {
/**
* Helper method to format message of OldDot Actions.
*/
function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldDotReportAction): string {
function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldDotReportAction, withMarkdown = true): string {
if (isOldDotLegacyAction(oldDotAction)) {
return getMessageOfOldDotLegacyAction(oldDotAction);
}
Expand Down Expand Up @@ -1269,7 +1247,7 @@ function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldD
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');
return Localize.translateLocal(`report.actions.type.selectedForRandomAudit${withMarkdown ? 'Markdown' : ''}`);
case CONST.REPORT.ACTIONS.TYPE.SHARE:
return Localize.translateLocal('report.actions.type.share', {to: originalMessage.to});
case CONST.REPORT.ACTIONS.TYPE.UNSHARE:
Expand All @@ -1281,11 +1259,47 @@ function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldD
}
}

function getMemberChangeMessageFragment(reportAction: OnyxEntry<ReportAction>): Message {
const messageElements: readonly MemberChangeMessageElement[] = getMemberChangeMessageElements(reportAction);
const html = messageElements
.map((messageElement) => {
switch (messageElement.kind) {
case 'userMention':
return `<mention-user accountID=${messageElement.accountID}>${messageElement.content}</mention-user>`;
case 'roomReference':
return `<a href="${environmentURL}/r/${messageElement.roomID}" target="_blank">${messageElement.roomName}</a>`;
default:
return messageElement.content;
}
})
.join('');

return {
html: `<muted-text>${html}</muted-text>`,
text: getReportActionMessage(reportAction) ? getReportActionText(reportAction) : '',
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
};
}

function getMemberChangeMessagePlainText(reportAction: OnyxEntry<ReportAction>): string {
const messageElements = getMemberChangeMessageElements(reportAction);
return messageElements.map((element) => element.content).join('');
}

function getReportActionMessageFragments(action: ReportAction): Message[] {
if (isOldDotReportAction(action)) {
const oldDotMessage = getMessageOfOldDotReportAction(action);
const html = isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT) ? Parser.replace(oldDotMessage) : oldDotMessage;
return [{text: oldDotMessage, html: `<muted-text>${html}</muted-text>`, type: 'COMMENT'}];
}

const actionMessage = action.previousMessage ?? action.message;
if (Array.isArray(actionMessage)) {
return actionMessage.filter((item): item is Message => !!item);
}
return actionMessage ? [actionMessage] : [];
}

/**
* Helper method to determine if the provided accountID has submitted an expense on the specified report.
*
Expand Down Expand Up @@ -1555,6 +1569,7 @@ export {
getLinkedTransactionID,
getMemberChangeMessageFragment,
getMemberChangeMessagePlainText,
getReportActionMessageFragments,
getMessageOfOldDotReportAction,
getMostRecentIOURequestActionID,
getMostRecentReportActionLastModified,
Expand Down
3 changes: 0 additions & 3 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,6 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={ReportUtils.getReimbursementDeQueuedActionMessage(action, report)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) {
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.SUBMITTED) {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUSubmittedMessage(report.reportID)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
Expand Down
9 changes: 1 addition & 8 deletions src/pages/home/report/ReportActionItemMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {ReportAction, Transaction} from '@src/types/onyx';
import type {Message} from '@src/types/onyx/ReportAction';
import TextCommentFragment from './comment/TextCommentFragment';
import ReportActionItemFragment from './ReportActionItemFragment';

Expand Down Expand Up @@ -42,13 +41,7 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID,
const styles = useThemeStyles();
const {translate} = useLocalize();

const actionMessage = action.previousMessage ?? action.message;
let fragments: Message[] = [];
if (Array.isArray(actionMessage)) {
fragments = actionMessage.filter((item): item is Message => !!item);
} else {
fragments = actionMessage ? [actionMessage] : [];
}
const fragments = ReportActionsUtils.getReportActionMessageFragments(action);
const isIOUReport = ReportActionsUtils.isMoneyRequestAction(action);

if (ReportActionsUtils.isMemberChangeAction(action)) {
Expand Down