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 @@ -186,7 +186,7 @@
*/
let currentUserLogin: string | undefined;
let currentUserAccountID: number | undefined;
Onyx.connect({

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

View workflow job for this annotation

GitHub Actions / ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 189 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 @@ -195,13 +195,13 @@
});

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

Check warning on line 198 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 204 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 @@ -213,14 +213,14 @@
});

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

Check warning on line 216 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 223 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 @@ -229,7 +229,7 @@
});

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

Check warning on line 232 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 @@ -241,7 +241,7 @@
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const lastVisibleReportActions: ReportActions = {};
Onyx.connect({

Check warning on line 244 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 @@ -303,7 +303,7 @@
});

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

Check warning on line 306 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 @@ -875,6 +875,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 @@ -1827,6 +1828,7 @@
excludeNonAdminWorkspaces,
isRestrictedToPreferredPolicy,
preferredPolicyID,
shouldAlwaysIncludeDM,
} = config;
const topmostReportId = Navigation.getTopmostReportId();

Expand Down Expand Up @@ -1922,7 +1924,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 @@ -853,6 +853,7 @@ type OptionData = {
isDefaultRoom?: boolean;
isInvoiceRoom?: boolean;
isExpenseReport?: boolean;
isDM?: boolean;
isOptimisticPersonalDetail?: boolean;
selected?: boolean;
isOptimisticAccount?: boolean;
Expand Down
11 changes: 10 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,14 @@ function NewChatPage({ref}: NewChatPageProps) {
Navigation.dismissModalWithReport({reportID: option.reportID});
return;
}
if (option?.reportID) {
Navigation.dismissModal({
callback: () => {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option?.reportID));
},
});
return;
}
if (selectedOptions.length && option) {
// Prevent excluded emails from being added to groups
if (option?.login && excludedGroupEmails.has(option.login)) {
Expand Down Expand Up @@ -371,7 +380,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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this change for?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not showing "Add to group" button when login doesn't exist?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@situchan Because we don't have the logic data which is used to create the group report.

return null;
}

Expand Down
Loading