Skip to content

Commit

Permalink
Merge pull request #30452 from bernhardoj/fix/30182-wrong-navigate-de…
Browse files Browse the repository at this point in the history
…tails

Fix pressing the task report (with assignee) header opens the assignee profile page
  • Loading branch information
Hayata Suenaga authored Oct 31, 2023
2 parents 5945510 + bd5becb commit 45da3b8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
46 changes: 22 additions & 24 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,27 @@ 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 participantAccountIDs = lodashGet(report, 'participantAccountIDs', []);
return (
!isThread(report) &&
!isChatRoom(report) &&
!isExpenseRequest(report) &&
!isMoneyRequestReport(report) &&
!isPolicyExpenseChat(report) &&
!isTaskReport(report) &&
isDM(report) &&
!isIOUReport(report) &&
participantAccountIDs.length === 1
);
}

/**
* Get the report given a reportID
*
Expand Down Expand Up @@ -2135,7 +2156,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;
}
Expand Down Expand Up @@ -3152,29 +3173,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.
Expand Down

0 comments on commit 45da3b8

Please sign in to comment.