From f1bc53dfbab959b7d676e05cb86669dfd3e9718a Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 25 Nov 2025 23:34:02 +0700 Subject: [PATCH 01/12] Expenses moved to Self DM, display a Join button on top of report --- src/libs/ReportUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ef6dd168b651..9d36acc2b00e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2480,9 +2480,9 @@ function isIOURequest(report: OnyxInputOrEntry): boolean { */ function isTrackExpenseReport(report: OnyxInputOrEntry): boolean { if (isThread(report)) { - const selfDMReportID = findSelfDMReportID(); + const parentReport = getParentReport(report); const parentReportAction = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.[report.parentReportActionID]; - return !isEmptyObject(parentReportAction) && selfDMReportID === report.parentReportID && isTrackExpenseAction(parentReportAction); + return !isEmptyObject(parentReportAction) && isSelfDM(parentReport) && isTrackExpenseAction(parentReportAction); } return false; } From 1fa8e2b3b038ed49170211891c90108e8a25339a Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 27 Nov 2025 22:44:15 +0700 Subject: [PATCH 02/12] implement isTrackExpenseReportNew function --- src/libs/ReportUtils.ts | 24 +++++++++++++++++++++--- src/pages/ReportDetailsPage.tsx | 2 +- src/pages/home/HeaderView.tsx | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f844b2fa07c5..b5c1cfb3180a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2480,7 +2480,19 @@ function isIOURequest(report: OnyxInputOrEntry): boolean { */ function isTrackExpenseReport(report: OnyxInputOrEntry): boolean { if (isThread(report)) { - const parentReport = getParentReport(report); + const selfDMReportID = findSelfDMReportID(); + const parentReportAction = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.[report.parentReportActionID]; + return !isEmptyObject(parentReportAction) && selfDMReportID === report.parentReportID && isTrackExpenseAction(parentReportAction); + } + return false; +} + +/** + * A Track Expense Report is a thread where the parent the parentReportAction is a transaction, and + * parentReportAction has type of track. + */ +function isTrackExpenseReportNew(report: OnyxInputOrEntry, parentReport: OnyxInputOrEntry): boolean { + if (isThread(report)) { const parentReportAction = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.[report.parentReportActionID]; return !isEmptyObject(parentReportAction) && isSelfDM(parentReport) && isTrackExpenseAction(parentReportAction); } @@ -10817,7 +10829,13 @@ function isAdminOwnerApproverOrReportOwner(report: OnyxEntry, policy: On /** * Whether the user can join a report */ -function canJoinChat(report: OnyxEntry, parentReportAction: OnyxInputOrEntry, policy: OnyxInputOrEntry, isReportArchived = false): boolean { +function canJoinChat( + report: OnyxEntry, + parentReportAction: OnyxInputOrEntry, + policy: OnyxInputOrEntry, + isReportArchived = false, + parentReport?: Report, +): boolean { // We disabled thread functions for whisper action // So we should not show join option for existing thread on whisper message that has already been left, or manually leave it if (isWhisperAction(parentReportAction)) { @@ -10829,7 +10847,7 @@ function canJoinChat(report: OnyxEntry, parentReportAction: OnyxInputOrE return false; } - const isExpenseChat = isMoneyRequestReport(report) || isMoneyRequest(report) || isInvoiceReport(report) || isTrackExpenseReport(report); + const isExpenseChat = isMoneyRequestReport(report) || isMoneyRequest(report) || isInvoiceReport(report) || isTrackExpenseReportNew(report, parentReport); // Anyone viewing these chat types is already a participant and therefore cannot join if (isRootGroupChat(report, isReportArchived) || isSelfDM(report) || isInvoiceRoom(report) || isSystemChat(report) || isExpenseChat) { return false; diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index f1330818d5cb..11fd3a44f232 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -663,7 +663,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail moneyRequestReport?.reportID, ]); - const canJoin = canJoinChat(report, parentReportAction, policy, !!reportNameValuePairs?.private_isArchived); + const canJoin = canJoinChat(report, parentReportAction, policy, !!reportNameValuePairs?.private_isArchived, parentReport); const promotedActions = useMemo(() => { const result: PromotedAction[] = []; diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index e36ae208c54b..7410c807fbfa 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -184,7 +184,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked, const join = callFunctionIfActionIsAllowed(() => joinRoom(report)); - const canJoin = canJoinChat(report, parentReportAction, policy, isReportArchived); + const canJoin = canJoinChat(report, parentReportAction, policy, isReportArchived, parentReport); const joinButton = (