From 6b716a343cbb3ee89d4c08860af142dcc71cf22b Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 17 Apr 2024 11:10:11 +0300 Subject: [PATCH 1/3] change comment link for parent message to link to the parent report --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 4f9d5e2788e6..5675bd2e2863 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -424,7 +424,8 @@ const ContextMenuActions: ContextMenuAction[] = [ onPress: (closePopover, {reportAction, reportID}) => { Environment.getEnvironmentURL().then((environmentURL) => { const reportActionID = reportAction?.reportActionID; - Clipboard.setString(`${environmentURL}/r/${reportID}/${reportActionID}`); + const linkedReportID = ReportUtils.isThreadFirstChat(reportAction, reportID) ? ReportUtils.getReport(reportID)?.parentReportID : reportID; + Clipboard.setString(`${environmentURL}/r/${linkedReportID}/${reportActionID}`); }); hideContextMenu(true, ReportActionComposeFocusManager.focus); }, From 93b7bdb0d8f4edf0f31c98357b249aa5c1a77316 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 17 Apr 2024 14:17:01 +0300 Subject: [PATCH 2/3] fixed expense report case bug --- src/libs/ReportUtils.ts | 10 ++++++---- src/libs/actions/ReportActions.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f31b4a780c5a..782ad435577d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5211,12 +5211,14 @@ function canUserPerformWriteAction(report: OnyxEntry) { /** * Returns ID of the original report from which the given reportAction is first created. */ -function getOriginalReportID(reportID: string, reportAction: OnyxEntry): string | undefined { +function getOriginalReportID(reportID: string, reportAction: OnyxEntry, shouldReturnTransactionThread = false): string | undefined { const reportActions = reportActionsByReport?.[reportID]; const currentReportAction = reportActions?.[reportAction?.reportActionID ?? ''] ?? null; - const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(reportID, reportActions ?? ([] as ReportAction[])); - if (transactionThreadReportID !== null) { - return Object.keys(currentReportAction ?? {}).length === 0 ? transactionThreadReportID : reportID; + if (shouldReturnTransactionThread) { + const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(reportID, reportActions ?? ([] as ReportAction[])); + if (transactionThreadReportID !== null) { + return Object.keys(currentReportAction ?? {}).length === 0 ? transactionThreadReportID : reportID; + } } return isThreadFirstChat(reportAction, reportID) && Object.keys(currentReportAction ?? {}).length === 0 ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.parentReportID diff --git a/src/libs/actions/ReportActions.ts b/src/libs/actions/ReportActions.ts index 610c5c67a0fa..f6b8cfa0838b 100644 --- a/src/libs/actions/ReportActions.ts +++ b/src/libs/actions/ReportActions.ts @@ -12,7 +12,7 @@ import * as Report from './Report'; type IgnoreDirection = 'parent' | 'child'; function clearReportActionErrors(reportID: string, reportAction: ReportAction, keys?: string[]) { - const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction); + const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction, true); if (!reportAction?.reportActionID) { return; From 8dce9db83189b18cb70d2a51fe3880dad52a4528 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 22 Apr 2024 20:16:27 +0300 Subject: [PATCH 3/3] replaced with getOriginalReportID --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 5675bd2e2863..e1bb4024a10d 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -424,8 +424,7 @@ const ContextMenuActions: ContextMenuAction[] = [ onPress: (closePopover, {reportAction, reportID}) => { Environment.getEnvironmentURL().then((environmentURL) => { const reportActionID = reportAction?.reportActionID; - const linkedReportID = ReportUtils.isThreadFirstChat(reportAction, reportID) ? ReportUtils.getReport(reportID)?.parentReportID : reportID; - Clipboard.setString(`${environmentURL}/r/${linkedReportID}/${reportActionID}`); + Clipboard.setString(`${environmentURL}/r/${ReportUtils.getOriginalReportID(reportID, reportAction)}/${reportActionID}`); }); hideContextMenu(true, ReportActionComposeFocusManager.focus); },