Skip to content

Commit

Permalink
fix: show persona chat only for onboarded by persona users
Browse files Browse the repository at this point in the history
  • Loading branch information
koko57 committed Jun 11, 2024
1 parent 0205df8 commit 08a87cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5347,6 +5347,8 @@ function shouldReportBeInOptionList({
report?.reportName === undefined ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
report?.isHidden ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
participantAccountIDs.includes(CONST.ACCOUNT_ID.NOTIFICATIONS) ||
(participantAccountIDs.length === 0 &&
!isChatThread(report) &&
!isPublicRoom(report) &&
Expand Down Expand Up @@ -5435,17 +5437,6 @@ function shouldReportBeInOptionList({
return true;
}

/**
* Returns the system report from the list of reports.
*/
function getSystemChat(): OnyxEntry<Report> {
if (!allReports) {
return null;
}

return Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) ?? null;
}

/**
* Attempts to find a report in onyx with the provided list of participants. Does not include threads, task, expense, room, and policy expense chat.
*/
Expand Down Expand Up @@ -7067,7 +7058,6 @@ export {
getRoomWelcomeMessage,
getRootParentReport,
getRouteFromLink,
getSystemChat,
getTaskAssigneeChatOnyxData,
getTransactionDetails,
getTransactionReportName,
Expand Down
7 changes: 7 additions & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type PriorityMode from '@src/types/onyx/PriorityMode';
import type Report from '@src/types/onyx/Report';
import type ReportAction from '@src/types/onyx/ReportAction';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import AccountUtils from './AccountUtils';
import * as CollectionUtils from './CollectionUtils';
import {hasValidDraftComment} from './DraftCommentUtils';
import localeCompare from './LocaleCompare';
Expand Down Expand Up @@ -104,6 +105,12 @@ function getOrderedReportIDs(
return false;
}

const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number);

if (currentUserAccountID && AccountUtils.isAccountIDOddNumber(currentUserAccountID) && participantAccountIDs.includes(CONST.ACCOUNT_ID.NOTIFICATIONS)) {
return true;
}

return ReportUtils.shouldReportBeInOptionList({
report,
currentReportId: currentReportId ?? '',
Expand Down

0 comments on commit 08a87cd

Please sign in to comment.