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
4 changes: 3 additions & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,9 @@ function getLastMessageTextForReport(
const properSchemaForModifiedExpenseMessage = ModifiedExpenseMessage.getForReportAction({reportOrID: report?.reportID, reportAction: lastReportAction});
lastMessageTextFromReport = formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true);
} else if (isMovedTransactionAction(lastReportAction)) {
lastMessageTextFromReport = getMovedTransactionMessage(lastReportAction);
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
const movedIOUReport = isExpenseReport(parentReport) ? parentReport : report;
lastMessageTextFromReport = getMovedTransactionMessage(lastReportAction, movedIOUReport);
} else if (isTaskAction(lastReportAction)) {
lastMessageTextFromReport = formatReportLastMessageText(getTaskReportActionMessage(lastReportAction).text);
} else if (isCreatedTaskReportAction(lastReportAction)) {
Expand Down
17 changes: 6 additions & 11 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import lodashMaxBy from 'lodash/maxBy';
import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {SvgProps} from 'react-native-svg';
import type {OriginalMessageChangePolicy, OriginalMessageExportIntegration, OriginalMessageModifiedExpense, OriginalMessageMovedTransaction} from 'src/types/onyx/OriginalMessage';
import type {OriginalMessageChangePolicy, OriginalMessageExportIntegration, OriginalMessageModifiedExpense} from 'src/types/onyx/OriginalMessage';
import type {SetRequired, TupleToUnion, ValueOf} from 'type-fest';
import {FallbackAvatar, IntacctSquare, NetSuiteSquare, QBOSquare, XeroSquare} from '@components/Icon/Expensicons';
import * as defaultGroupAvatars from '@components/Icon/GroupDefaultAvatars';
Expand Down Expand Up @@ -6081,18 +6081,13 @@ function getDeletedTransactionMessage(action: ReportAction) {
return message;
}

function getReportDetails(reportID: string): {reportName: string; reportUrl: string} {
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
return {
reportName: getReportName(report) ?? report?.reportName ?? '',
reportUrl: `${environmentURL}/r/${reportID}`,
};
function getReportUrl(reportID?: string) {
return `${environmentURL}/r/${reportID}`;
}

function getMovedTransactionMessage(action: ReportAction) {
const movedTransactionOriginalMessage = getOriginalMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION>) ?? {};
const {toReportID} = movedTransactionOriginalMessage as OriginalMessageMovedTransaction;
const {reportName, reportUrl} = getReportDetails(toReportID);
function getMovedTransactionMessage(parentReportAction: OnyxEntry<ReportAction>, movedIOUReport?: Report) {
const reportName = getReportName(movedIOUReport, undefined, parentReportAction) ?? movedIOUReport?.reportName ?? '';
const reportUrl = getReportUrl(movedIOUReport?.reportID);
const message = translateLocal('iou.movedTransaction', {
reportUrl,
reportName,
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,10 @@ function PureReportActionItem({
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) {
children = <ReportActionItemBasicMessage message={getDeletedTransactionMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION) {
const movedIOUReport = isExpenseReport(parentReport) ? parentReport : report;
children = (
<ReportActionItemBasicMessage message="">
<RenderHTML html={`<comment><muted-text>${getMovedTransactionMessage(action)}</muted-text></comment>`} />
<RenderHTML html={`<comment><muted-text>${getMovedTransactionMessage(parentReportAction, movedIOUReport)}</muted-text></comment>`} />
</ReportActionItemBasicMessage>
);
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) {
Expand Down