Skip to content

Commit 968f7a2

Browse files
authored
Merge pull request Expensify#71452 from bernhardoj/fix/70444-missing-message-sender
Fix missing message sender
2 parents e552a49 + 5e2373e commit 968f7a2

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

src/libs/ReportActionsUtils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,13 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key:
863863
return false;
864864
}
865865

866+
if (isMovedTransactionAction(reportAction)) {
867+
const movedTransactionOriginalMessage = getOriginalMessage(reportAction);
868+
const toReportID = movedTransactionOriginalMessage?.toReportID;
869+
const toReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${toReportID}`];
870+
return !!toReport;
871+
}
872+
866873
// Ignore closed action here since we're already displaying a footer that explains why the report was closed
867874
if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED && !isMarkAsClosedAction(reportAction)) {
868875
return false;

src/libs/SearchUIUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ import {
8181
isMoneyRequestAction,
8282
isResolvedActionableWhisper,
8383
isWhisperActionTargetedToOthers,
84+
shouldReportActionBeVisible,
8485
} from './ReportActionsUtils';
8586
import {canReview} from './ReportPreviewActionUtils';
8687
import {isExportAction} from './ReportPrimaryActionUtils';
8788
import {
89+
canUserPerformWriteAction,
8890
getIcons,
8991
getPersonalDetailsForAccountID,
9092
getReportName,
@@ -1326,6 +1328,7 @@ function getReportActionsSections(data: OnyxTypes.SearchResults['data']): Report
13261328
const invoiceReceiverPolicy: SearchPolicy | undefined =
13271329
report?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.BUSINESS ? data[`${ONYXKEYS.COLLECTION.POLICY}${report.invoiceReceiver.policyID}`] : undefined;
13281330
if (
1331+
!shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction(report, isReportArchived)) ||
13291332
isDeletedAction(reportAction) ||
13301333
isResolvedActionableWhisper(reportAction) ||
13311334
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED ||

tests/unit/ReportActionsUtilsTest.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,42 @@ describe('ReportActionsUtils', () => {
13841384
});
13851385
});
13861386

1387+
describe('shouldReportActionBeVisible', () => {
1388+
it('should return false for moved transaction if the report destination is unavailable', () => {
1389+
// Given a moved transaction action but the report destination is not available
1390+
const reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION> = {
1391+
actionName: CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION,
1392+
reportActionID: '1',
1393+
created: '2025-09-29',
1394+
originalMessage: {
1395+
toReportID: '2',
1396+
},
1397+
};
1398+
1399+
// Then the action should not be visible
1400+
const actual = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true);
1401+
expect(actual).toBe(false);
1402+
});
1403+
1404+
it('should return true for moved transaction if the report destination is available', async () => {
1405+
// Given a moved transaction action but the report destination is available
1406+
const report: Report = createRandomReport(2);
1407+
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report);
1408+
const reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION> = {
1409+
actionName: CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION,
1410+
reportActionID: '1',
1411+
created: '2025-09-29',
1412+
originalMessage: {
1413+
toReportID: report.reportID,
1414+
},
1415+
};
1416+
1417+
// Then the action should be visible
1418+
const actual = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true);
1419+
expect(actual).toBe(true);
1420+
});
1421+
});
1422+
13871423
describe('getPolicyChangeLogUpdateEmployee', () => {
13881424
it('should remove SMS domain when the email is a phone number', () => {
13891425
const email = '+919383833920@expensify.sms';

0 commit comments

Comments
 (0)