From 587535aec4baef79b223d8cfb93fb80c7fde5d21 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 3 Aug 2023 14:36:38 +0700 Subject: [PATCH 1/6] fix regression --- src/libs/ReportUtils.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 91c35d4cd956..0542bad72b9d 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -411,9 +411,15 @@ function isOptimisticPersonalDetail(accountID) { * @returns {Boolean} */ function shouldDisableDetailPage(report) { - const participants = lodashGet(report, 'participantAccountIDs', []); - const isMultipleParticipant = participants.length > 1; - return !isMultipleParticipant && isOptimisticPersonalDetail(participants[0]) && !report.parentReportID; + const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); + + if (isChatRoom(report) || isPolicyExpenseChat(report) || isChatThread(report)) { + return false; + } + if (participantAccountIDs.length === 1) { + return isOptimisticPersonalDetail(participantAccountIDs[0]); + } + return false; } /** From 4b5babb6140c4d824e1d65b5e36e472843ce2c8a Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 3 Aug 2023 14:53:49 +0700 Subject: [PATCH 2/6] fix lint --- src/libs/ReportUtils.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 0542bad72b9d..a766030b947f 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -405,23 +405,6 @@ function isOptimisticPersonalDetail(accountID) { return _.isEmpty(allPersonalDetails[accountID]) || !!allPersonalDetails[accountID].isOptimisticPersonalDetail; } -/** - * Check if report is a DM and personal detail of participant is optimistic data - * @param {String} report - * @returns {Boolean} - */ -function shouldDisableDetailPage(report) { - const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); - - if (isChatRoom(report) || isPolicyExpenseChat(report) || isChatThread(report)) { - return false; - } - if (participantAccountIDs.length === 1) { - return isOptimisticPersonalDetail(participantAccountIDs[0]); - } - return false; -} - /** * Checks if a report is a task report from a policy expense chat. * @@ -466,6 +449,23 @@ function isConciergeChatReport(report) { return lodashGet(report, 'participantAccountIDs', []).length === 1 && Number(report.participantAccountIDs[0]) === CONST.ACCOUNT_ID.CONCIERGE && !isChatThread(report); } +/** + * Check if report is a DM and personal detail of participant is optimistic data + * @param {String} report + * @returns {Boolean} + */ +function shouldDisableDetailPage(report) { + const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); + + if (isChatRoom(report) || isPolicyExpenseChat(report) || isChatThread(report)) { + return false; + } + if (participantAccountIDs.length === 1) { + return isOptimisticPersonalDetail(participantAccountIDs[0]); + } + return false; +} + /** * Returns true if there are any Expensify accounts (i.e. with domain 'expensify.com') in the set of accountIDs * by cross-referencing the accountIDs with personalDetails. From 512ad731c9f15af9fa15a7b9f297fe25560dacdb Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Fri, 4 Aug 2023 21:49:59 +0700 Subject: [PATCH 3/6] Update src/libs/ReportUtils.js Co-authored-by: Alex Beaman --- src/libs/ReportUtils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 3fd0c51e1a0c..37964e905998 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -451,7 +451,8 @@ function isConciergeChatReport(report) { /** * Check if report is a DM and personal detail of participant is optimistic data - * @param {String} report + * @param {Object} report + * @param {Array} report.participantAccountIDs * @returns {Boolean} */ function shouldDisableDetailPage(report) { From 62f39d94934c40f5b4b291f18399249d27ed4f47 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 4 Aug 2023 22:13:11 +0700 Subject: [PATCH 4/6] edit description --- src/libs/ReportUtils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 0542bad72b9d..46f7714e7ffc 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -406,7 +406,8 @@ function isOptimisticPersonalDetail(accountID) { } /** - * Check if report is a DM and personal detail of participant is optimistic data + * Check if the report is a single chat report that isn't a thread + * and personal detail of participant is optimistic data * @param {String} report * @returns {Boolean} */ From 37f438fd203696ea6548f446c7d08081d2684147 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 4 Aug 2023 22:15:55 +0700 Subject: [PATCH 5/6] edit type of param --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index cc16988ba8cd..68996a929fd5 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -408,7 +408,7 @@ function isOptimisticPersonalDetail(accountID) { /** * Check if the report is a single chat report that isn't a thread * and personal detail of participant is optimistic data - * @param {String} report + * @param {Object} report * @returns {Boolean} */ function shouldDisableDetailPage(report) { From e8c1e863054706c22247f4d49dd93882cc592717 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 4 Aug 2023 22:27:01 +0700 Subject: [PATCH 6/6] remove duplicate --- src/libs/ReportUtils.js | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 68996a929fd5..327611fa0191 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -405,24 +405,6 @@ function isOptimisticPersonalDetail(accountID) { return _.isEmpty(allPersonalDetails[accountID]) || !!allPersonalDetails[accountID].isOptimisticPersonalDetail; } -/** - * Check if the report is a single chat report that isn't a thread - * and personal detail of participant is optimistic data - * @param {Object} report - * @returns {Boolean} - */ -function shouldDisableDetailPage(report) { - const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); - - if (isChatRoom(report) || isPolicyExpenseChat(report) || isChatThread(report)) { - return false; - } - if (participantAccountIDs.length === 1) { - return isOptimisticPersonalDetail(participantAccountIDs[0]); - } - return false; -} - /** * Checks if a report is a task report from a policy expense chat. * @@ -468,9 +450,10 @@ function isConciergeChatReport(report) { } /** - * Check if report is a DM and personal detail of participant is optimistic data + * Check if the report is a single chat report that isn't a thread + * and personal detail of participant is optimistic data * @param {Object} report - * @param {Array} report.participantAccountIDs + * @param {Array} report.participantAccountIDs * @returns {Boolean} */ function shouldDisableDetailPage(report) {