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
16 changes: 6 additions & 10 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ type GetUserToInviteConfig = {
excludeUnknownUsers?: boolean;
optionsToExclude?: Array<Partial<ReportUtils.OptionData>>;
selectedOptions?: Array<Partial<ReportUtils.OptionData>>;
betas: OnyxEntry<Beta[]>;
reportActions?: ReportActions;
showChatPreviewLine?: boolean;
};
Expand Down Expand Up @@ -219,10 +218,10 @@ type Options = {

type PreviewConfig = {showChatPreviewLine?: boolean; forcePolicyNamePreview?: boolean; showPersonalDetails?: boolean};

type FilterOptionsConfig = Pick<
GetOptionsConfig,
'sortByReportTypeInSearch' | 'canInviteUser' | 'betas' | 'selectedOptions' | 'excludeUnknownUsers' | 'excludeLogins' | 'maxRecentReportsToShow'
> & {preferChatroomsOverThreads?: boolean; includeChatRoomsByParticipants?: boolean};
type FilterOptionsConfig = Pick<GetOptionsConfig, 'sortByReportTypeInSearch' | 'canInviteUser' | 'selectedOptions' | 'excludeUnknownUsers' | 'excludeLogins' | 'maxRecentReportsToShow'> & {
preferChatroomsOverThreads?: boolean;
includeChatRoomsByParticipants?: boolean;
};

type HasText = {
text?: string;
Expand Down Expand Up @@ -1727,7 +1726,7 @@ function getUserToInviteOption({
/**
* Check whether report has violations
*/
function shouldShowViolations(report: Report, betas: OnyxEntry<Beta[]>, transactionViolations: OnyxCollection<TransactionViolation[]>) {
function shouldShowViolations(report: Report, transactionViolations: OnyxCollection<TransactionViolation[]>) {
const {parentReportID, parentReportActionID} = report ?? {};
const canGetParentReport = parentReportID && parentReportActionID && allReportActions;
if (!canGetParentReport) {
Expand Down Expand Up @@ -1850,7 +1849,7 @@ function getOptions(
// Filter out all the reports that shouldn't be displayed
const filteredReportOptions = options.reports.filter((option) => {
const report = option.item;
const doesReportHaveViolations = shouldShowViolations(report, betas, transactionViolations);
const doesReportHaveViolations = shouldShowViolations(report, transactionViolations);

return ReportUtils.shouldReportBeInOptionList({
report,
Expand Down Expand Up @@ -2053,7 +2052,6 @@ function getOptions(
excludeUnknownUsers,
optionsToExclude,
selectedOptions,
betas,
reportActions,
showChatPreviewLine,
});
Expand Down Expand Up @@ -2421,7 +2419,6 @@ function filterOptions(options: Options, searchInputValue: string, config?: Filt
const {
sortByReportTypeInSearch = false,
canInviteUser = true,
betas = [],
maxRecentReportsToShow = 0,
excludeLogins = [],
preferChatroomsOverThreads = false,
Expand Down Expand Up @@ -2526,7 +2523,6 @@ function filterOptions(options: Options, searchInputValue: string, config?: Filt
if (recentReports.length === 0 && personalDetails.length === 0) {
userToInvite = getUserToInviteOption({
searchValue,
betas,
selectedOptions: config?.selectedOptions,
optionsToExclude,
});
Expand Down
4 changes: 2 additions & 2 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function getOrderedReportIDs(
}
const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {};
const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1');
const doesReportHaveViolations = OptionsListUtils.shouldShowViolations(report, betas ?? [], transactionViolations);
const doesReportHaveViolations = OptionsListUtils.shouldShowViolations(report, transactionViolations);
const isHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
const isFocused = report.reportID === currentReportId;
const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {};
Expand All @@ -111,7 +111,7 @@ function getOrderedReportIDs(
let doesTransactionThreadReportHasViolations = false;
if (oneTransactionThreadReportID) {
const transactionReport = ReportUtils.getReport(oneTransactionThreadReportID);
doesTransactionThreadReportHasViolations = !!transactionReport && OptionsListUtils.shouldShowViolations(transactionReport, betas ?? [], transactionViolations);
doesTransactionThreadReportHasViolations = !!transactionReport && OptionsListUtils.shouldShowViolations(transactionReport, transactionViolations);
}
const hasErrorsOtherThanFailedReceipt =
doesTransactionThreadReportHasViolations ||
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ChatFinderPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa
}

Timing.start(CONST.TIMING.SEARCH_FILTER_OPTIONS);
const newOptions = OptionsListUtils.filterOptions(searchOptions, debouncedSearchValue, {sortByReportTypeInSearch: true, betas, preferChatroomsOverThreads: true});
const newOptions = OptionsListUtils.filterOptions(searchOptions, debouncedSearchValue, {sortByReportTypeInSearch: true, preferChatroomsOverThreads: true});
Timing.end(CONST.TIMING.SEARCH_FILTER_OPTIONS);

const header = OptionsListUtils.getHeaderMessage(newOptions.recentReports.length + Number(!!newOptions.userToInvite) > 0, false, debouncedSearchValue);
Expand All @@ -114,7 +114,7 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa
userToInvite: newOptions.userToInvite,
headerMessage: header,
};
}, [debouncedSearchValue, searchOptions, betas]);
}, [debouncedSearchValue, searchOptions]);

const {recentReports, personalDetails: localPersonalDetails, userToInvite, headerMessage} = debouncedSearchValue.trim() !== '' ? filteredOptions : searchOptions;

Expand Down
3 changes: 1 addition & 2 deletions src/pages/NewChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ function useOptions({isGroupChat}: NewChatPageProps) {
if (!participantOption) {
participantOption = OptionsListUtils.getUserToInviteOption({
searchValue: participant.login,
betas,
});
}
if (!participantOption) {
Expand All @@ -128,7 +127,7 @@ function useOptions({isGroupChat}: NewChatPageProps) {
});
});
setSelectedOptions(newSelectedOptions);
}, [newGroupDraft?.participants, listOptions.personalDetails, betas, personalData.accountID]);
}, [newGroupDraft?.participants, listOptions.personalDetails, personalData.accountID]);

return {
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,12 @@ function MoneyRequestParticipantsSelector({participants = CONST.EMPTY_ARRAY, onF
}

const newOptions = OptionsListUtils.filterOptions(defaultOptions, debouncedSearchTerm, {
betas,
selectedOptions: participants as Participant[],
excludeLogins: CONST.EXPENSIFY_EMAILS,
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
});
return newOptions;
}, [areOptionsInitialized, betas, defaultOptions, debouncedSearchTerm, participants]);
}, [areOptionsInitialized, defaultOptions, debouncedSearchTerm, participants]);

/**
* Returns the sections needed for the OptionsSelector
Expand Down