Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
*/
let currentUserLogin: string | undefined;
let currentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 194 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserLogin = value?.email;
Expand All @@ -200,13 +200,13 @@
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 203 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = isEmptyObject(value) ? {} : value),
});

const policies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 209 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
callback: (policy, key) => {
if (!policy || !key || !policy.name) {
Expand All @@ -218,14 +218,14 @@
});

let allPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 221 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (val) => (allPolicies = val),
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 228 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -234,7 +234,7 @@
});

let allReportNameValuePairs: OnyxCollection<ReportNameValuePairs>;
Onyx.connect({

Check warning on line 237 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -246,7 +246,7 @@
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const lastVisibleReportActions: ReportActions = {};
Onyx.connect({

Check warning on line 249 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -308,7 +308,7 @@
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 311 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});
Expand Down Expand Up @@ -893,6 +893,7 @@
isSelfDM: report ? reportUtilsIsSelfDM(report) : false,
isChatRoom: report ? reportUtilsIsChatRoom(report) : false,
isInvoiceRoom: report ? isInvoiceRoom(report) : false,
isDM: report ? isDM(report) : false,

// Status properties - used in SearchOption context
private_isArchived: undefined, // Set from reportNameValuePairs below
Expand Down Expand Up @@ -1845,6 +1846,7 @@
excludeNonAdminWorkspaces,
isRestrictedToPreferredPolicy,
preferredPolicyID,
shouldAlwaysIncludeDM,
} = config;
const topmostReportId = Navigation.getTopmostReportId();

Expand Down Expand Up @@ -1940,7 +1942,7 @@
- It doesn't have a login
- It is not an invoice room that should be shown
*/
if (!isCurrentUserOwnedPolicyExpenseChatThatCouldShow && !includeMultipleParticipantReports && !option.login && !shouldShowInvoiceRoom) {
if (!isCurrentUserOwnedPolicyExpenseChatThatCouldShow && !includeMultipleParticipantReports && !option.login && (!option.isDM || !shouldAlwaysIncludeDM) && !shouldShowInvoiceRoom) {
return false;
}

Expand Down
3 changes: 3 additions & 0 deletions src/libs/OptionsListUtils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type SearchOptionData = Pick<
| 'isChatRoom'
| 'isInvoiceRoom'
| 'isDefaultRoom'
| 'isDM'

// Status properties
| 'private_isArchived'
Expand Down Expand Up @@ -155,6 +156,7 @@ type GetValidReportsConfig = {
isRestrictedToPreferredPolicy?: boolean;
preferredPolicyID?: string;
shouldUnreadBeBold?: boolean;
shouldAlwaysIncludeDM?: boolean;
} & GetValidOptionsSharedConfig;

type IsValidReportsConfig = Pick<
Expand All @@ -176,6 +178,7 @@ type IsValidReportsConfig = Pick<
| 'excludeNonAdminWorkspaces'
| 'isRestrictedToPreferredPolicy'
| 'preferredPolicyID'
| 'shouldAlwaysIncludeDM'
>;

type GetOptionsConfig = {
Expand Down
1 change: 1 addition & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ type OptionData = {
isDefaultRoom?: boolean;
isInvoiceRoom?: boolean;
isExpenseReport?: boolean;
isDM?: boolean;
isOptimisticPersonalDetail?: boolean;
selected?: boolean;
isOptimisticAccount?: boolean;
Expand Down
13 changes: 12 additions & 1 deletion src/pages/NewChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function useOptions() {
{
betas: betas ?? [],
includeSelfDM: true,
shouldAlwaysIncludeDM: true,
},
countryCode,
);
Expand Down Expand Up @@ -342,6 +343,7 @@ function NewChatPage({ref}: NewChatPageProps) {
Navigation.dismissModalWithReport({reportID: option.reportID});
return;
}

if (selectedOptions.length && option) {
// Prevent excluded emails from being added to groups
if (option?.login && excludedGroupEmails.has(option.login)) {
Expand All @@ -351,6 +353,15 @@ function NewChatPage({ref}: NewChatPageProps) {
return;
}

if (option?.reportID) {
Navigation.dismissModal({
callback: () => {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option?.reportID));
},
});
return;
}

let login = '';

if (option?.login) {
Expand All @@ -371,7 +382,7 @@ function NewChatPage({ref}: NewChatPageProps) {

const itemRightSideComponent = useCallback(
(item: ListItem & Option, isFocused?: boolean) => {
if (!!item.isSelfDM || (item.login && excludedGroupEmails.has(item.login))) {
if (!!item.isSelfDM || (item.login && excludedGroupEmails.has(item.login)) || !item.login) {
return null;
}

Expand Down
Loading