From f3849242bc38dc44d4f5aa91420bdf84e4b0fb18 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 26 Oct 2023 23:58:28 +0800 Subject: [PATCH 1/4] navigate to profile only if it's a 1:1 chat --- 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 66aa32fe2a56..2649d7db9142 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2125,7 +2125,7 @@ function getParentNavigationSubtitle(report) { function navigateToDetailsPage(report) { const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); - if (isDM(report) && participantAccountIDs.length === 1) { + if (isOneOnOneChat(report)) { Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountIDs[0])); return; } From e681d30bd4dfbd092a108e97140d9a41128ce016 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 27 Oct 2023 00:21:43 +0800 Subject: [PATCH 2/4] move isOneOnOneChat definition up --- src/libs/ReportUtils.js | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 2649d7db9142..4d14f2060c49 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -772,6 +772,29 @@ function isMoneyRequestReport(reportOrID) { return isIOUReport(report) || isExpenseReport(report); } +/** + * Should return true only for personal 1:1 report + * + * @param {Object} report (chatReport or iouReport) + * @returns {boolean} + */ +function isOneOnOneChat(report) { + const isChatRoomValue = lodashGet(report, 'isChatRoom', false); + const participantsListValue = lodashGet(report, 'participantsList', []); + return ( + !isThread(report) && + !isChatRoom(report) && + !isChatRoomValue && + !isExpenseRequest(report) && + !isMoneyRequestReport(report) && + !isPolicyExpenseChat(report) && + !isTaskReport(report) && + isDM(report) && + !isIOUReport(report) && + participantsListValue.length === 1 + ); +} + /** * Get the report given a reportID * @@ -3139,29 +3162,6 @@ function isIOUOwnedByCurrentUser(report, allReportsDict = null) { return reportToLook.ownerAccountID === currentUserAccountID; } -/** - * Should return true only for personal 1:1 report - * - * @param {Object} report (chatReport or iouReport) - * @returns {boolean} - */ -function isOneOnOneChat(report) { - const isChatRoomValue = lodashGet(report, 'isChatRoom', false); - const participantsListValue = lodashGet(report, 'participantsList', []); - return ( - !isThread(report) && - !isChatRoom(report) && - !isChatRoomValue && - !isExpenseRequest(report) && - !isMoneyRequestReport(report) && - !isPolicyExpenseChat(report) && - !isTaskReport(report) && - isDM(report) && - !isIOUReport(report) && - participantsListValue.length === 1 - ); -} - /** * Assuming the passed in report is a default room, lets us know whether we can see it or not, based on permissions and * the various subsets of users we've allowed to use default rooms. From 7caa628f63cb7e9c2b334aabcdba8492e80f4c09 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 31 Oct 2023 14:41:10 +0800 Subject: [PATCH 3/4] use the correct report data --- src/components/LHNOptionsList/OptionRowLHN.js | 2 +- src/libs/ReportUtils.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index f83e0b834287..51d81b756e7a 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -152,7 +152,7 @@ function OptionRowLHN(props) { const statusClearAfterDate = lodashGet(optionItem, 'status.clearAfter', ''); const formattedDate = DateUtils.getStatusUntilDate(statusClearAfterDate); const statusContent = formattedDate ? `${statusText} (${formattedDate})` : statusText; - const isStatusVisible = Permissions.canUseCustomStatus(props.betas) && !!emojiCode && ReportUtils.isOneOnOneChat(optionItem); + const isStatusVisible = Permissions.canUseCustomStatus(props.betas) && !!emojiCode && ReportUtils.isOneOnOneChat(ReportUtils.getReport(optionItem.reportID)); const isGroupChat = optionItem.type === CONST.REPORT.TYPE.CHAT && _.isEmpty(optionItem.chatType) && !optionItem.isThread && lodashGet(optionItem, 'displayNamesWithTooltips.length', 0) > 2; diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 15f95dd88b0c..e825e36dc86c 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -779,19 +779,17 @@ function isMoneyRequestReport(reportOrID) { * @returns {boolean} */ function isOneOnOneChat(report) { - const isChatRoomValue = lodashGet(report, 'isChatRoom', false); - const participantsListValue = lodashGet(report, 'participantsList', []); + const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); return ( !isThread(report) && !isChatRoom(report) && - !isChatRoomValue && !isExpenseRequest(report) && !isMoneyRequestReport(report) && !isPolicyExpenseChat(report) && !isTaskReport(report) && isDM(report) && !isIOUReport(report) && - participantsListValue.length === 1 + participantAccountIDs.length === 1 ); } @@ -2158,6 +2156,7 @@ function getParentNavigationSubtitle(report) { function navigateToDetailsPage(report) { const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); + console.log('report', report) if (isOneOnOneChat(report)) { Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountIDs[0])); return; From bd5becb897361e53becd0446b803634e555346d6 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 31 Oct 2023 14:52:43 +0800 Subject: [PATCH 4/4] remove console --- src/libs/ReportUtils.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index e825e36dc86c..28135c7fd3ca 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2156,7 +2156,6 @@ function getParentNavigationSubtitle(report) { function navigateToDetailsPage(report) { const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); - console.log('report', report) if (isOneOnOneChat(report)) { Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountIDs[0])); return;