Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide contact option if we don't include P2P option #42142

Merged
merged 7 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
15 changes: 5 additions & 10 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ type GetOptionsConfig = {
maxRecentReportsToShow?: number;
excludeLogins?: string[];
includeMultipleParticipantReports?: boolean;
includePersonalDetails?: boolean;
includeRecentReports?: boolean;
includeSelfDM?: boolean;
sortByReportTypeInSearch?: boolean;
Expand Down Expand Up @@ -1648,7 +1647,6 @@ function getOptions(
maxRecentReportsToShow = 0,
excludeLogins = [],
includeMultipleParticipantReports = false,
includePersonalDetails = false,
includeRecentReports = false,
// When sortByReportTypeInSearch flag is true, recentReports will include the personalDetails options as well.
sortByReportTypeInSearch = false,
Expand Down Expand Up @@ -1831,7 +1829,7 @@ function getOptions(
return option;
});

const havingLoginPersonalDetails = options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail);
const havingLoginPersonalDetails = includeP2P ? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail) : [];
Copy link
Contributor

Choose a reason for hiding this comment

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

based on your comment shouldn't we cleanup includePersonalDetails if it's redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@getusha I updated to cleanup includePersonalDetails.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice I like that.

NAB: We could remove the variable havingLoginPersonalDetails since its unnecessary.

let allPersonalDetailsOptions = havingLoginPersonalDetails;

if (sortPersonalDetailsByAlphaAsc) {
Expand Down Expand Up @@ -1917,7 +1915,7 @@ function getOptions(
}
}

if (includePersonalDetails) {
if (includeP2P) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this condition will not be redundant? we're assigning an empty array above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@getusha You're right, I updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

@nkdengineer I am still not sure if we want to keep the code that was under this condition. could you please confirm that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@getusha The code that was under this condition is used to create personal detail option so it's necessary.

Copy link
Contributor

@getusha getusha May 24, 2024

Choose a reason for hiding this comment

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

@nkdengineer sorry, i was just confused because the code was supposed to run only under that condition right? removing only the condition didn't make any sense, can you check it again? and lets make sure we test this thoroughly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const havingLoginPersonalDetails = includeP2P ? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail) : [];

@getusha

  1. We update this to only filter havingLoginPersonalDetails if includeP2P is true

  2. The code under the condition is calculated the personal detail option based on havingLoginPersonalDetails so we need to keep this code. we can remove the condition because we applied the condition at point 1.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, thanks

const personalDetailsOptionsToExclude = [...optionsToExclude, {login: currentUserLogin}];
// Next loop over all personal details removing any that are selectedUsers or recentChats
allPersonalDetailsOptions.forEach((personalDetailOption) => {
Expand Down Expand Up @@ -1990,7 +1988,7 @@ function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] =
maxRecentReportsToShow: 0, // Unlimited
sortByReportTypeInSearch: true,
showChatPreviewLine: true,
includePersonalDetails: true,
includeP2P: true,
forcePolicyNamePreview: true,
includeOwnedWorkspaceChats: true,
includeThreads: true,
Expand All @@ -2011,7 +2009,7 @@ function getShareLogOptions(options: OptionList, searchValue = '', betas: Beta[]
includeRecentReports: true,
includeMultipleParticipantReports: true,
sortByReportTypeInSearch: true,
includePersonalDetails: true,
includeP2P: true,
forcePolicyNamePreview: true,
includeOwnedWorkspaceChats: true,
includeSelfDM: true,
Expand Down Expand Up @@ -2068,7 +2066,6 @@ function getFilteredOptions(
includePolicyReportFieldOptions = false,
policyReportFieldOptions: string[] = [],
recentlyUsedPolicyReportFieldOptions: string[] = [],
includePersonalDetails = true,
maxRecentReportsToShow = 5,
) {
return getOptions(
Expand All @@ -2078,7 +2075,6 @@ function getFilteredOptions(
searchInputValue: searchValue.trim(),
selectedOptions,
includeRecentReports: true,
includePersonalDetails,
maxRecentReportsToShow,
excludeLogins,
includeOwnedWorkspaceChats,
Expand Down Expand Up @@ -2124,7 +2120,6 @@ function getShareDestinationOptions(
maxRecentReportsToShow: 0, // Unlimited
includeRecentReports: true,
includeMultipleParticipantReports: true,
includePersonalDetails: false,
showChatPreviewLine: true,
forcePolicyNamePreview: true,
includeThreads: true,
Expand Down Expand Up @@ -2181,7 +2176,7 @@ function getMemberInviteOptions(
{
betas,
searchInputValue: searchValue.trim(),
includePersonalDetails: true,
includeP2P: true,
excludeLogins,
sortPersonalDetailsByAlphaAsc: true,
includeSelectedOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
undefined,
undefined,
undefined,
!isCategorizeOrShareAction,
isCategorizeOrShareAction ? 0 : undefined,
);

Expand Down
3 changes: 1 addition & 2 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ describe('OptionsListUtils', () => {
undefined,
undefined,
undefined,
false,
undefined,
undefined,
undefined,
Expand All @@ -490,8 +491,6 @@ describe('OptionsListUtils', () => {
undefined,
undefined,
undefined,
undefined,
false,
);

// Then no personal detail options will be returned
Expand Down
Loading