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
7 changes: 7 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
type MemberChangeMessageElement = MessageTextElement | MemberChangeMessageUserMentionElement | MemberChangeMessageRoomReferenceElement;

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 58 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -67,7 +67,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 70 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -76,14 +76,14 @@
});

let isNetworkOffline = false;
Onyx.connect({

Check warning on line 79 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NETWORK,
callback: (val) => (isNetworkOffline = val?.isOffline ?? false),
});

let currentUserAccountID: number | undefined;
let currentEmail = '';
Onyx.connect({

Check warning on line 86 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, value is undefined
Expand All @@ -97,7 +97,7 @@
});

let privatePersonalDetails: PrivatePersonalDetails | undefined;
Onyx.connect({

Check warning on line 100 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS,
callback: (personalDetails) => {
privatePersonalDetails = personalDetails;
Expand Down Expand Up @@ -863,6 +863,13 @@
return false;
}

if (isMovedTransactionAction(reportAction)) {
const movedTransactionOriginalMessage = getOriginalMessage(reportAction);
const toReportID = movedTransactionOriginalMessage?.toReportID;
const toReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${toReportID}`];
return !!toReport;
}

// Ignore closed action here since we're already displaying a footer that explains why the report was closed
if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED && !isMarkAsClosedAction(reportAction)) {
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ import {
isMoneyRequestAction,
isResolvedActionableWhisper,
isWhisperActionTargetedToOthers,
shouldReportActionBeVisible,
} from './ReportActionsUtils';
import {canReview} from './ReportPreviewActionUtils';
import {isExportAction} from './ReportPrimaryActionUtils';
import {
canUserPerformWriteAction,
getIcons,
getPersonalDetailsForAccountID,
getReportName,
Expand Down Expand Up @@ -1326,6 +1328,7 @@ function getReportActionsSections(data: OnyxTypes.SearchResults['data']): Report
const invoiceReceiverPolicy: SearchPolicy | undefined =
report?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.BUSINESS ? data[`${ONYXKEYS.COLLECTION.POLICY}${report.invoiceReceiver.policyID}`] : undefined;
if (
!shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction(report, isReportArchived)) ||
isDeletedAction(reportAction) ||
isResolvedActionableWhisper(reportAction) ||
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED ||
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/ReportActionsUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,42 @@ describe('ReportActionsUtils', () => {
});
});

describe('shouldReportActionBeVisible', () => {
it('should return false for moved transaction if the report destination is unavailable', () => {
// Given a moved transaction action but the report destination is not available
const reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION> = {
actionName: CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION,
reportActionID: '1',
created: '2025-09-29',
originalMessage: {
toReportID: '2',
},
};

// Then the action should not be visible
const actual = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true);
expect(actual).toBe(false);
});

it('should return true for moved transaction if the report destination is available', async () => {
// Given a moved transaction action but the report destination is available
const report: Report = createRandomReport(2);
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report);
const reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION> = {
actionName: CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION,
reportActionID: '1',
created: '2025-09-29',
originalMessage: {
toReportID: report.reportID,
},
};

// Then the action should be visible
const actual = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true);
expect(actual).toBe(true);
});
});

describe('getPolicyChangeLogUpdateEmployee', () => {
it('should remove SMS domain when the email is a phone number', () => {
const email = '+919383833920@expensify.sms';
Expand Down
Loading