Skip to content

Commit 2dcf2fc

Browse files
authored
Merge pull request Expensify#77889 from Expensify/mollfpr-fix-migrated-unreported-expense
Fix migrated unreported expense showing not found page
2 parents d9b7219 + 39a8072 commit 2dcf2fc

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/libs/SearchUIUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import {
9090
import {isExportAction} from './ReportPrimaryActionUtils';
9191
import {
9292
canUserPerformWriteAction,
93+
findSelfDMReportID,
9394
generateReportID,
9495
getIcons,
9596
getPersonalDetailsForAccountID,
@@ -1556,7 +1557,8 @@ function createAndOpenSearchTransactionThread(
15561557
transactionPreviewData?: TransactionPreviewData,
15571558
shouldNavigate = true,
15581559
) {
1559-
const iouReportAction = getIOUActionForReportID(item.reportID, item.transactionID);
1560+
const isFromSelfDM = item.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;
1561+
const iouReportAction = getIOUActionForReportID(isFromSelfDM ? findSelfDMReportID() : item.reportID, item.transactionID);
15601562
const moneyRequestReportActionID = item.reportAction?.reportActionID ?? undefined;
15611563
const previewData = transactionPreviewData
15621564
? {...transactionPreviewData, hasTransactionThreadReport: true}
@@ -1581,7 +1583,6 @@ function createAndOpenSearchTransactionThread(
15811583
if (shouldNavigate) {
15821584
// Navigate to transaction thread if there are multiple transactions in the report, or to the parent report if it's the only transaction
15831585
const isFromOneTransactionReport = isOneTransactionReport(item.report);
1584-
const isFromSelfDM = item.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;
15851586
const shouldNavigateToTransactionThread = (!isFromOneTransactionReport || isFromSelfDM) && transactionThreadReport?.reportID !== CONST.REPORT.UNREPORTED_REPORT_ID;
15861587
const targetReportID = shouldNavigateToTransactionThread ? transactionThreadReport?.reportID : item.reportID;
15871588

src/libs/actions/Report.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ function openReport(
10621062
const submitterPersonalDetails = PersonalDetailsUtils.getPersonalDetailByEmail(submitterEmail);
10631063

10641064
const optimisticIOUAction = buildOptimisticIOUReportAction({
1065-
type: CONST.IOU.REPORT_ACTION_TYPE.CREATE,
1065+
type: isSelfDM(parentReport) ? CONST.IOU.REPORT_ACTION_TYPE.TRACK : CONST.IOU.REPORT_ACTION_TYPE.CREATE,
10661066
amount: Math.abs(transaction.amount),
10671067
currency: transaction.currency,
10681068
comment: transaction.comment?.comment ?? '',
@@ -1395,8 +1395,7 @@ function createTransactionThreadReport(
13951395
const selfDMReportID = isTrackExpense || isUnreportedTransaction ? findSelfDMReportID() : undefined;
13961396

13971397
let reportToUse = iouReport;
1398-
// For track expenses without iouReport, get the selfDM report
1399-
if (isTrackExpense && selfDMReportID) {
1398+
if (selfDMReportID) {
14001399
reportToUse = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`];
14011400
}
14021401

0 commit comments

Comments
 (0)