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
11 changes: 8 additions & 3 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1622,9 +1622,14 @@ function createAndOpenSearchTransactionThread(
// For legacy transactions without an IOU action in the backend, pass transaction data
// This allows OpenReport to create the IOU action and transaction thread on the backend
const reportActionID = moneyRequestReportActionID ?? iouReportAction?.reportActionID;
const transaction = !reportActionID ? getTransactionFromTransactionListItem(item) : undefined;
const transactionViolations = !reportActionID ? item.violations : undefined;
transactionThreadReport = createTransactionThreadReport(item.report, {reportActionID} as OnyxTypes.ReportAction, transaction, transactionViolations);
// Pass transaction data when there's no reportActionID OR when the item is from self DM
// (unreported transactions have a valid reportActionID but still need transaction data for proper detection)
const shouldPassTransactionData = !reportActionID || isFromSelfDM;
const transaction = shouldPassTransactionData ? getTransactionFromTransactionListItem(item) : undefined;
const transactionViolations = shouldPassTransactionData ? item.violations : undefined;
// Use the full reportAction to preserve originalMessage.type (e.g., "track") for proper expense type detection
const reportActionToPass = iouReportAction ?? item.reportAction ?? ({reportActionID} as OnyxTypes.ReportAction);
transactionThreadReport = createTransactionThreadReport(item.report, reportActionToPass, transaction, transactionViolations);
}

if (shouldNavigate) {
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Search/SearchUIUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3249,7 +3249,8 @@ describe('SearchUIUtils', () => {
SearchUIUtils.createAndOpenSearchTransactionThread(transactionListItem, backTo, threadReportID, undefined, false);

expect(setOptimisticDataForTransactionThreadPreview).toHaveBeenCalled();
expect(createTransactionThreadReport).toHaveBeenCalledWith(report1, {reportActionID: '11111111'}, undefined, undefined);
// The full reportAction is passed to preserve originalMessage.type for proper expense type detection
expect(createTransactionThreadReport).toHaveBeenCalledWith(report1, reportAction1, undefined, undefined);
});

test('Should not navigate if shouldNavigate = false', () => {
Expand Down
Loading