From 432dd76a200a3da76ad991b0f262c1638966a0af Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 6 Nov 2024 11:02:33 +0700 Subject: [PATCH 1/7] fix: hold and unhold expense page is not scrolling down --- src/libs/actions/IOU.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 7a72df9f1d87..772f4c183c45 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8111,6 +8111,11 @@ function putOnHold(transactionID: string, comment: string, reportID: string, sea }, {optimisticData, successData, failureData}, ); + + const report = ReportUtils.getReport(reportID); + const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); + const currentReportID = ReportUtils.isOneTransactionThread(report?.reportID ?? '', report?.parentReportID ?? '', parentReportAction) ? report?.parentReportID : reportID; + Report.notifyNewAction(currentReportID ?? '', userAccountID); } /** @@ -8210,6 +8215,11 @@ function unholdRequest(transactionID: string, reportID: string, searchHash?: num }, {optimisticData, successData, failureData}, ); + + const report = ReportUtils.getReport(reportID); + const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); + const currentReportID = ReportUtils.isOneTransactionThread(report?.reportID ?? '', report?.parentReportID ?? '', parentReportAction) ? report?.parentReportID : reportID; + Report.notifyNewAction(currentReportID ?? '', userAccountID); } // eslint-disable-next-line rulesdir/no-negated-variables function navigateToStartStepIfScanFileCannotBeRead( From ff68df4488cb800f88b0ff0f0a61fb108f936b07 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 7 Nov 2024 11:32:42 +0700 Subject: [PATCH 2/7] add utils function --- src/libs/ReportUtils.ts | 8 ++++++++ src/libs/actions/IOU.ts | 8 ++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a62716975c01..8d555bb0b1b4 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1698,6 +1698,13 @@ function isOneTransactionThread(reportID: string, parentReportID: string, thread return reportID === transactionThreadReportID && !ReportActionsUtils.isSentMoneyReportAction(threadParentReportAction); } +function getCurrentReportIDInOneTransactionThread(reportID: string) { + const report = getReport(reportID); + const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); + const currentReportID = isOneTransactionThread(report?.reportID ?? '', report?.parentReportID ?? '', parentReportAction) ? report?.parentReportID : reportID; + return currentReportID; +} + /** * Should return true only for personal 1:1 report * @@ -8553,6 +8560,7 @@ export { getTaskAssigneeChatOnyxData, getTransactionDetails, getTransactionReportName, + getCurrentReportIDInOneTransactionThread, getTransactionsWithReceipts, getUserDetailTooltipText, getWhisperDisplayNames, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 772f4c183c45..a27459eab835 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8112,9 +8112,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string, sea {optimisticData, successData, failureData}, ); - const report = ReportUtils.getReport(reportID); - const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); - const currentReportID = ReportUtils.isOneTransactionThread(report?.reportID ?? '', report?.parentReportID ?? '', parentReportAction) ? report?.parentReportID : reportID; + const currentReportID = ReportUtils.getCurrentReportIDInOneTransactionThread(reportID); Report.notifyNewAction(currentReportID ?? '', userAccountID); } @@ -8216,9 +8214,7 @@ function unholdRequest(transactionID: string, reportID: string, searchHash?: num {optimisticData, successData, failureData}, ); - const report = ReportUtils.getReport(reportID); - const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); - const currentReportID = ReportUtils.isOneTransactionThread(report?.reportID ?? '', report?.parentReportID ?? '', parentReportAction) ? report?.parentReportID : reportID; + const currentReportID = ReportUtils.getCurrentReportIDInOneTransactionThread(reportID); Report.notifyNewAction(currentReportID ?? '', userAccountID); } // eslint-disable-next-line rulesdir/no-negated-variables From 2fd062cc041e197de02897ac790f75fcd037f168 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 8 Nov 2024 10:42:55 +0700 Subject: [PATCH 3/7] fix: rename and add comment to function --- src/libs/ReportUtils.ts | 10 ++++++---- src/libs/actions/IOU.ts | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8d555bb0b1b4..2430889b1098 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1698,11 +1698,13 @@ function isOneTransactionThread(reportID: string, parentReportID: string, thread return reportID === transactionThreadReportID && !ReportActionsUtils.isSentMoneyReportAction(threadParentReportAction); } -function getCurrentReportIDInOneTransactionThread(reportID: string) { +/** + * Get displayed repport ID in one transaction thread + */ +function getDisplayedReportID(reportID: string): string { const report = getReport(reportID); const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); - const currentReportID = isOneTransactionThread(report?.reportID ?? '', report?.parentReportID ?? '', parentReportAction) ? report?.parentReportID : reportID; - return currentReportID; + return (isOneTransactionThread(report?.reportID ?? '', report?.parentReportID ?? '', parentReportAction) ? report?.parentReportID : reportID) ?? ''; } /** @@ -8560,7 +8562,7 @@ export { getTaskAssigneeChatOnyxData, getTransactionDetails, getTransactionReportName, - getCurrentReportIDInOneTransactionThread, + getDisplayedReportID, getTransactionsWithReceipts, getUserDetailTooltipText, getWhisperDisplayNames, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 83b354c085bc..8eed2dd44092 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8127,7 +8127,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string, sea {optimisticData, successData, failureData}, ); - const currentReportID = ReportUtils.getCurrentReportIDInOneTransactionThread(reportID); + const currentReportID = ReportUtils.getDisplayedReportID(reportID); Report.notifyNewAction(currentReportID ?? '', userAccountID); } @@ -8229,7 +8229,7 @@ function unholdRequest(transactionID: string, reportID: string, searchHash?: num {optimisticData, successData, failureData}, ); - const currentReportID = ReportUtils.getCurrentReportIDInOneTransactionThread(reportID); + const currentReportID = ReportUtils.getDisplayedReportID(reportID); Report.notifyNewAction(currentReportID ?? '', userAccountID); } // eslint-disable-next-line rulesdir/no-negated-variables From ba450cf12a9277930196674eb49277cad353bc6d Mon Sep 17 00:00:00 2001 From: nkdengineer <161821005+nkdengineer@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:07:22 +0700 Subject: [PATCH 4/7] Update src/libs/ReportUtils.ts Co-authored-by: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2430889b1098..a978fbaf325d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1699,7 +1699,7 @@ function isOneTransactionThread(reportID: string, parentReportID: string, thread } /** - * Get displayed repport ID in one transaction thread + * Get displayed report ID, it will be parentReportID if the report is one transaction thread */ function getDisplayedReportID(reportID: string): string { const report = getReport(reportID); From 04c530a484d4772a7048030d681f381aa8aa1d5b Mon Sep 17 00:00:00 2001 From: nkdengineer <161821005+nkdengineer@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:07:29 +0700 Subject: [PATCH 5/7] Update src/libs/actions/IOU.ts Co-authored-by: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8eed2dd44092..8f837bcbf175 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8230,7 +8230,7 @@ function unholdRequest(transactionID: string, reportID: string, searchHash?: num ); const currentReportID = ReportUtils.getDisplayedReportID(reportID); - Report.notifyNewAction(currentReportID ?? '', userAccountID); + Report.notifyNewAction(currentReportID, userAccountID); } // eslint-disable-next-line rulesdir/no-negated-variables function navigateToStartStepIfScanFileCannotBeRead( From 15e308e684a39290c80d620f5abcc052d48526c6 Mon Sep 17 00:00:00 2001 From: nkdengineer <161821005+nkdengineer@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:07:40 +0700 Subject: [PATCH 6/7] Update src/libs/actions/IOU.ts Co-authored-by: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8f837bcbf175..b6c4377eb54b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8128,7 +8128,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string, sea ); const currentReportID = ReportUtils.getDisplayedReportID(reportID); - Report.notifyNewAction(currentReportID ?? '', userAccountID); + Report.notifyNewAction(currentReportID, userAccountID); } /** From 8142c68eb440f3d8e4422f8e0928c3a68ee63975 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 11 Nov 2024 22:36:44 +0700 Subject: [PATCH 7/7] fix: refactor function code --- src/libs/ReportUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ec9818ef8db2..a48613a633c4 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1705,8 +1705,9 @@ function isOneTransactionThread(reportID: string, parentReportID: string, thread */ function getDisplayedReportID(reportID: string): string { const report = getReport(reportID); - const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); - return (isOneTransactionThread(report?.reportID ?? '', report?.parentReportID ?? '', parentReportAction) ? report?.parentReportID : reportID) ?? ''; + const parentReportID = report?.parentReportID ?? ''; + const parentReportAction = ReportActionsUtils.getReportAction(parentReportID, report?.parentReportActionID ?? ''); + return isOneTransactionThread(reportID, parentReportID, parentReportAction) ? parentReportID : reportID; } /**