Skip to content

Commit 058bae6

Browse files
committed
check the action with another way
1 parent b9c7e8b commit 058bae6

5 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/libs/OptionsListUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
836836
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION)) {
837837
lastMessageTextFromReport = getDeletedTransactionMessage(lastReportAction);
838838
} else if (isMovedAction(lastReportAction)) {
839-
lastMessageTextFromReport = getMovedActionMessage(lastReportAction);
839+
lastMessageTextFromReport = getMovedActionMessage(lastReportAction, report);
840840
}
841841

842842
// we do not want to show report closed in LHN for non archived report so use getReportLastMessage as fallback instead of lastMessageText from report

src/libs/ReportUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5136,6 +5136,7 @@ function getReportNameInternal({
51365136
}: GetReportNameParams): string {
51375137
let formattedName: string | undefined;
51385138
let parentReportAction: OnyxEntry<ReportAction>;
5139+
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
51395140
if (parentReportActionParam) {
51405141
parentReportAction = parentReportActionParam;
51415142
} else {
@@ -5225,7 +5226,7 @@ function getReportNameInternal({
52255226
}
52265227

52275228
if (isMovedAction(parentReportAction)) {
5228-
return getMovedActionMessage(parentReportAction);
5229+
return getMovedActionMessage(parentReportAction, parentReport);
52295230
}
52305231

52315232
if (isMoneyRequestAction(parentReportAction)) {
@@ -6227,7 +6228,7 @@ function getMovedTransactionMessage(report: OnyxEntry<Report>) {
62276228
return message;
62286229
}
62296230

6230-
function getMovedActionMessage(action: ReportAction) {
6231+
function getMovedActionMessage(action: ReportAction, report: OnyxEntry<Report>) {
62316232
if (!isMovedAction(action)) {
62326233
return '';
62336234
}
@@ -6236,11 +6237,10 @@ function getMovedActionMessage(action: ReportAction) {
62366237
if (!movedActionOriginalMessage) {
62376238
return '';
62386239
}
6239-
const html = getReportActionHtml(action);
62406240
const {toPolicyID, newParentReportID, movedReportID} = movedActionOriginalMessage;
62416241
const toPolicyName = getPolicyNameByID(toPolicyID);
62426242
return translateLocal('iou.movedAction', {
6243-
shouldHideMovedReportUrl: html.startsWith('moved this report'),
6243+
shouldHideMovedReportUrl: !isDM(report),
62446244
movedReportUrl: `${environmentURL}/r/${movedReportID}`,
62456245
newParentReportUrl: `${environmentURL}/r/${newParentReportID}`,
62466246
toPolicyName,

src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ function BaseReportActionContextMenu({
347347
setIsEmojiPickerActive,
348348
moneyRequestAction,
349349
card,
350+
originalReport,
350351
};
351352

352353
if ('renderContent' in contextAction) {

src/pages/home/report/ContextMenu/ContextMenuActions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ type ContextMenuActionPayload = {
195195
anchorRef?: RefObject<View | null>;
196196
moneyRequestAction: ReportAction | undefined;
197197
card?: Card;
198+
originalReport: OnyxEntry<ReportType>;
198199
};
199200

200201
type OnPress = (closePopover: boolean, payload: ContextMenuActionPayload, selection?: string, reportID?: string, draftMessage?: string) => void;
@@ -492,7 +493,7 @@ const ContextMenuActions: ContextMenuAction[] = [
492493
// If return value is true, we switch the `text` and `icon` on
493494
// `ContextMenuItem` with `successText` and `successIcon` which will fall back to
494495
// the `text` and `icon`
495-
onPress: (closePopover, {reportAction, transaction, selection, report, reportID, card}) => {
496+
onPress: (closePopover, {reportAction, transaction, selection, report, reportID, card, originalReport}) => {
496497
const isReportPreviewAction = isReportPreviewActionReportActionsUtils(reportAction);
497498
const messageHtml = getActionHtml(reportAction);
498499
const messageText = getReportActionMessageText(reportAction);
@@ -669,7 +670,7 @@ const ContextMenuActions: ContextMenuAction[] = [
669670
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD)) {
670671
setClipboardMessage(getUpdatedManualApprovalThresholdMessage(reportAction));
671672
} else if (isMovedAction(reportAction)) {
672-
setClipboardMessage(getMovedActionMessage(reportAction));
673+
setClipboardMessage(getMovedActionMessage(reportAction, originalReport));
673674
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY) {
674675
const displayMessage = getPolicyChangeMessage(reportAction);
675676
Clipboard.setString(displayMessage);

src/pages/home/report/PureReportActionItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ function PureReportActionItem({
10991099
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MOVED) {
11001100
children = (
11011101
<ReportActionItemBasicMessage message="">
1102-
<RenderHTML html={`<comment><muted-text>${getMovedActionMessage(action)}</muted-text></comment>`} />
1102+
<RenderHTML html={`<comment><muted-text>${getMovedActionMessage(action, report)}</muted-text></comment>`} />
11031103
</ReportActionItemBasicMessage>
11041104
);
11051105
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) {

0 commit comments

Comments
 (0)