Skip to content
Closed
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
6 changes: 4 additions & 2 deletions src/components/Search/FilterDropdowns/UserSelectPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ function UserSelectPopup({value, closeOverlay, onChange}: UserSelectPopupProps)
const [accountID] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true, selector: accountIDSelector});
const shouldFocusInputOnScreenFocus = canFocusInputOnScreenFocus();
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

const [searchTerm, setSearchTerm] = useState('');
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true});
const initialSelectedOptions = useMemo(() => {
Expand Down Expand Up @@ -95,12 +97,12 @@ function UserSelectPopup({value, closeOverlay, onChange}: UserSelectPopupProps)
}, [options.reports, options.personalDetails]);

const filteredOptions = useMemo(() => {
return filterAndOrderOptions(optionsList, cleanSearchTerm, countryCode, {
return filterAndOrderOptions(optionsList, cleanSearchTerm, countryCode, activePolicyID, {
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
canInviteUser: false,
});
}, [optionsList, cleanSearchTerm, countryCode]);
}, [optionsList, cleanSearchTerm, countryCode, activePolicyID]);

const listData = useMemo(() => {
const personalDetailList = filteredOptions.personalDetails.map((participant) => ({
Expand Down
6 changes: 4 additions & 2 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ function SearchAutocompleteList({
return getAutocompleteRecentCategories(allRecentCategories);
}, [allRecentCategories]);

const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

const [policies = getEmptyObject<NonNullable<OnyxCollection<Policy>>>()] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false});
const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: emailSelector, canBeMissing: false});
const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector, canBeMissing: false});
Expand Down Expand Up @@ -605,7 +607,7 @@ function SearchAutocompleteList({
return searchOptions.recentReports;
}

const orderedOptions = combineOrderingOfReportsAndPersonalDetails(searchOptions, autocompleteQueryValue, {
const orderedOptions = combineOrderingOfReportsAndPersonalDetails(searchOptions, autocompleteQueryValue, activePolicyID, {
sortByReportTypeInSearch: true,
preferChatRoomsOverThreads: true,
});
Expand Down Expand Up @@ -643,7 +645,7 @@ function SearchAutocompleteList({
});
throw error;
}
}, [autocompleteQueryValue, searchOptions]);
}, [activePolicyID, autocompleteQueryValue, searchOptions]);

const debounceHandleSearch = useDebounce(
useCallback(() => {
Expand Down
6 changes: 4 additions & 2 deletions src/components/Search/SearchFiltersChatsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen

const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true});
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true});
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportsSelector});
const [selectedReportIDs, setSelectedReportIDs] = useState<string[]>(initialReportIDs);
Expand All @@ -70,11 +72,11 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen
}, [areOptionsInitialized, isScreenTransitionEnd, options]);

const chatOptions = useMemo(() => {
return filterAndOrderOptions(defaultOptions, cleanSearchTerm, countryCode, {
return filterAndOrderOptions(defaultOptions, cleanSearchTerm, countryCode, activePolicyID, {
selectedOptions,
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
});
}, [defaultOptions, cleanSearchTerm, selectedOptions, countryCode]);
}, [defaultOptions, cleanSearchTerm, countryCode, activePolicyID, selectedOptions]);

const {sections, headerMessage} = useMemo(() => {
const newSections: Section[] = [];
Expand Down
6 changes: 4 additions & 2 deletions src/components/Search/SearchFiltersParticipantsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}:
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {canBeMissing: false, initWithStoredValues: false});
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportsSelector});
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

const [selectedOptions, setSelectedOptions] = useState<OptionData[]>([]);
const [searchTerm, setSearchTerm] = useState('');
const cleanSearchTerm = useMemo(() => searchTerm.trim().toLowerCase(), [searchTerm]);
Expand All @@ -75,7 +77,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}:
}, [defaultOptions, selectedOptions]);

const chatOptions = useMemo(() => {
const filteredOptions = filterAndOrderOptions(unselectedOptions, cleanSearchTerm, countryCode, {
const filteredOptions = filterAndOrderOptions(unselectedOptions, cleanSearchTerm, countryCode, activePolicyID, {
selectedOptions,
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
Expand All @@ -90,7 +92,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}:
}

return filteredOptions;
}, [unselectedOptions, cleanSearchTerm, selectedOptions, countryCode]);
}, [unselectedOptions, cleanSearchTerm, countryCode, activePolicyID, selectedOptions]);

const {sections, headerMessage} = useMemo(() => {
const newSections: Section[] = [];
Expand Down
28 changes: 12 additions & 16 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,6 @@ Onyx.connect({
},
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});

let nvpDismissedProductTraining: OnyxEntry<DismissedProductTraining>;
Onyx.connect({
key: ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING,
Expand Down Expand Up @@ -1214,6 +1208,7 @@ function optionsOrderBy<T = SearchOptionData>(options: T[], comparator: (option:
function orderReportOptionsWithSearch(
options: SearchOptionData[],
searchValue: string,
activePolicyID?: string,
{preferChatRoomsOverThreads = false, preferPolicyExpenseChat = false, preferRecentExpenseReports = false}: OrderReportOptionsConfig = {},
) {
const orderedByDate = orderReportOptions(options);
Expand Down Expand Up @@ -1260,7 +1255,7 @@ function orderReportOptionsWithSearch(
);
}

function orderWorkspaceOptions(options: SearchOptionData[]): SearchOptionData[] {
function orderWorkspaceOptions(options: SearchOptionData[], activePolicyID: string | undefined): SearchOptionData[] {
return options.sort((a, b) => {
// Check if `a` is the default workspace
if (a.isPolicyExpenseChat && a.policyID === activePolicyID) {
Expand Down Expand Up @@ -1289,21 +1284,21 @@ function sortComparatorReportOptionByDate(options: SearchOptionData) {
/**
* Sorts reports and personal details independently.
*/
function orderOptions(options: ReportAndPersonalDetailOptions): ReportAndPersonalDetailOptions;
function orderOptions(options: ReportAndPersonalDetailOptions, activePolicyID?: string): ReportAndPersonalDetailOptions;

/**
* Sorts reports and personal details independently, but prioritizes the search value.
*/
function orderOptions(options: ReportAndPersonalDetailOptions, searchValue: string, config?: OrderReportOptionsConfig): ReportAndPersonalDetailOptions;
function orderOptions(options: ReportAndPersonalDetailOptions, searchValue?: string, config?: OrderReportOptionsConfig): ReportAndPersonalDetailOptions {
function orderOptions(options: ReportAndPersonalDetailOptions, activePolicyID: string, searchValue: string, config?: OrderReportOptionsConfig): ReportAndPersonalDetailOptions;
function orderOptions(options: ReportAndPersonalDetailOptions, activePolicyID?: string, searchValue?: string, config?: OrderReportOptionsConfig): ReportAndPersonalDetailOptions {
let orderedReportOptions: SearchOptionData[];
if (searchValue) {
orderedReportOptions = orderReportOptionsWithSearch(options.recentReports, searchValue, config);
orderedReportOptions = orderReportOptionsWithSearch(options.recentReports, searchValue, activePolicyID, config);
} else {
orderedReportOptions = orderReportOptions(options.recentReports);
}
const orderedPersonalDetailsOptions = orderPersonalDetailsOptions(options.personalDetails);
const orderedWorkspaceChats = orderWorkspaceOptions(options?.workspaceChats ?? []);
const orderedWorkspaceChats = orderWorkspaceOptions(options?.workspaceChats ?? [], activePolicyID);

return {
recentReports: orderedReportOptions,
Expand Down Expand Up @@ -2458,16 +2453,17 @@ type FilterAndOrderConfig = FilterUserToInviteConfig & AllOrderConfigs;
function combineOrderingOfReportsAndPersonalDetails(
options: ReportAndPersonalDetailOptions,
searchInputValue: string,
activePolicyID?: string,
{maxRecentReportsToShow, sortByReportTypeInSearch, ...orderReportOptionsConfig}: AllOrderConfigs = {},
): ReportAndPersonalDetailOptions {
// sortByReportTypeInSearch will show the personal details as part of the recent reports
if (sortByReportTypeInSearch) {
const personalDetailsWithoutDMs = filteredPersonalDetailsOfRecentReports(options.recentReports, options.personalDetails);
const reportsAndPersonalDetails = options.recentReports.concat(personalDetailsWithoutDMs);
return orderOptions({recentReports: reportsAndPersonalDetails, personalDetails: []}, searchInputValue, orderReportOptionsConfig);
return orderOptions({recentReports: reportsAndPersonalDetails, personalDetails: []}, activePolicyID ?? '', searchInputValue, orderReportOptionsConfig);

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.

Do not default string IDs to any value

@parasharrajat parasharrajat Sep 12, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This parameter is required, so how do we manage that? I had to make this parameter required because of the different types this function support.

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.

Do not default string IDs to any value

This is lint error message 😄

@parasharrajat parasharrajat Sep 13, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But as I said, the param to the function is required but the activePolicyID is optional so we need to make sure it is not undefined but the value of this param can be empty which is a fine case.

So to satisfy ts, we need to pass a default value.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@DylanDylann What do you suggest on how we handle this?

Here are 2 variants of this function.

function orderOptions(options: ReportAndPersonalDetailOptions, activePolicyID?: string): ReportAndPersonalDetailOptions;

/**
 * Sorts reports and personal details independently, but prioritizes the search value.
 */
function orderOptions(options: ReportAndPersonalDetailOptions, activePolicyID: string, searchValue: string, config?: OrderReportOptionsConfig): ReportAndPersonalDetailOptions;
function orderOptions(options: ReportAndPersonalDetailOptions, activePolicyID?: string, searchValue?: string, config?: OrderReportOptionsConfig): ReportAndPersonalDetailOptions {

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.

@parasharrajat Why do we need to make activePolicyID as required while It could be undefined?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In the second function declaration above, third param searchValue is required so we have to make second param required and as we need activePolicyID in all 3 declarations, I have to position it as second param.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you agree with this?

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.

@parasharrajat Sorry for the delay. Thanks for bump

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.

Initially, this function overload provided type safety and improved IntelliSense. However, in this PR, the returned type was unified across the overloads.

Screenshot 2025-10-05 at 11 26 00

Because of that, the overload now seems redundant. I suggest removing it, which would also resolve the issue we’re facing here. Let me know what you think.

}

let orderedReports = orderReportOptionsWithSearch(options.recentReports, searchInputValue, orderReportOptionsConfig);
let orderedReports = orderReportOptionsWithSearch(options.recentReports, searchInputValue, activePolicyID, orderReportOptionsConfig);
if (typeof maxRecentReportsToShow === 'number') {
orderedReports = orderedReports.slice(0, maxRecentReportsToShow);
}
Expand All @@ -2485,13 +2481,13 @@ function combineOrderingOfReportsAndPersonalDetails(
* Filters and orders the options based on the search input value.
* Note that personal details that are part of the recent reports will always be shown as part of the recent reports (ie. DMs).
*/
function filterAndOrderOptions(options: Options, searchInputValue: string, countryCode: OnyxEntry<number>, config: FilterAndOrderConfig = {}): Options {
function filterAndOrderOptions(options: Options, searchInputValue: string, countryCode: OnyxEntry<number>, activePolicyID?: string, config: FilterAndOrderConfig = {}): Options {
let filterResult = options;
if (searchInputValue.trim().length > 0) {
filterResult = filterOptions(options, searchInputValue, countryCode, config);
}

const orderedOptions = combineOrderingOfReportsAndPersonalDetails(filterResult, searchInputValue, config);
const orderedOptions = combineOrderingOfReportsAndPersonalDetails(filterResult, searchInputValue, activePolicyID, config);

// on staging server, in specific cases (see issue) BE returns duplicated personalDetails entries
const uniqueLogins = new Set<string>();
Expand Down
6 changes: 4 additions & 2 deletions src/pages/NewChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function useOptions() {
const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true});
const [newGroupDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, {canBeMissing: true});
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

const personalData = useCurrentUserPersonalDetails();
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const [didScreenTransitionEnd, setDidScreenTransitionEnd] = useState(false);
Expand All @@ -88,13 +90,13 @@ function useOptions() {
const unselectedOptions = useMemo(() => filterSelectedOptions(defaultOptions, new Set(selectedOptions.map(({accountID}) => accountID))), [defaultOptions, selectedOptions]);

const options = useMemo(() => {
const filteredOptions = filterAndOrderOptions(unselectedOptions, debouncedSearchTerm, countryCode, {
const filteredOptions = filterAndOrderOptions(unselectedOptions, debouncedSearchTerm, countryCode, activePolicyID, {
selectedOptions,
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
});

return filteredOptions;
}, [debouncedSearchTerm, unselectedOptions, selectedOptions, countryCode]);
}, [unselectedOptions, debouncedSearchTerm, countryCode, activePolicyID, selectedOptions]);
const cleanSearchTerm = useMemo(() => debouncedSearchTerm.trim().toLowerCase(), [debouncedSearchTerm]);
const headerMessage = useMemo(() => {
return getHeaderMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false});
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const currentUserPersonalDetails = useCurrentUserPersonalDetails();

const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

const session = useSession();
const {isBetaEnabled} = usePermissions();
const {options, areOptionsInitialized} = useOptionsList({
Expand Down Expand Up @@ -95,8 +98,8 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
}, [areOptionsInitialized, betas, excludedUsers, options.personalDetails]);

const inviteOptions = useMemo(
() => filterAndOrderOptions(defaultOptions, debouncedSearchTerm, countryCode, {excludeLogins: excludedUsers}),
[debouncedSearchTerm, defaultOptions, excludedUsers, countryCode],
() => filterAndOrderOptions(defaultOptions, debouncedSearchTerm, countryCode, activePolicyID, {excludeLogins: excludedUsers}),
[defaultOptions, debouncedSearchTerm, countryCode, activePolicyID, excludedUsers],
);

useEffect(() => {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/RoomInvitePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function RoomInvitePage({
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(userSearchPhrase ?? '');
const [selectedOptions, setSelectedOptions] = useState<OptionData[]>([]);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const isReportArchived = useReportIsArchived(report.reportID);

const {options, areOptionsInitialized} = useOptionsList();
Expand Down Expand Up @@ -113,10 +114,10 @@ function RoomInvitePage({
if (debouncedSearchTerm.trim() === '') {
return defaultOptions;
}
const filteredOptions = filterAndOrderOptions(defaultOptions, debouncedSearchTerm, countryCode, {excludeLogins: excludedUsers});
const filteredOptions = filterAndOrderOptions(defaultOptions, debouncedSearchTerm, countryCode, activePolicyID, {excludeLogins: excludedUsers});

return filteredOptions;
}, [debouncedSearchTerm, defaultOptions, excludedUsers, countryCode]);
}, [debouncedSearchTerm, defaultOptions, countryCode, activePolicyID, excludedUsers]);

const sections = useMemo(() => {
const sectionsArr: Sections = [];
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Share/ShareTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function ShareTab({ref}: ShareTabProps) {
const {options, areOptionsInitialized} = useOptionsList();
const {didScreenTransitionEnd} = useScreenWrapperTransitionStatus();
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

const offlineMessage: string = isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : '';
const showLoadingPlaceholder = useMemo(() => !areOptionsInitialized || !didScreenTransitionEnd, [areOptionsInitialized, didScreenTransitionEnd]);
Expand All @@ -67,7 +68,7 @@ function ShareTab({ref}: ShareTabProps) {
if (textInputValue.trim() === '') {
return optionsOrderBy(searchOptions.recentReports, recentReportComparator, 20);
}
const orderedOptions = combineOrderingOfReportsAndPersonalDetails(searchOptions, textInputValue, {
const orderedOptions = combineOrderingOfReportsAndPersonalDetails(searchOptions, textInputValue, activePolicyID, {
sortByReportTypeInSearch: true,
preferChatRoomsOverThreads: true,
});
Expand All @@ -77,7 +78,7 @@ function ShareTab({ref}: ShareTabProps) {
reportOptions.push(searchOptions.userToInvite);
}
return reportOptions.slice(0, 20);
}, [searchOptions, textInputValue]);
}, [activePolicyID, searchOptions, textInputValue]);

useEffect(() => {
searchInServer(debouncedTextInputValue.trim());
Expand Down
10 changes: 6 additions & 4 deletions src/pages/iou/request/MoneyRequestAccountantSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
const offlineMessage: string = isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : '';
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportsSelector});

const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});

useEffect(() => {
searchInServer(debouncedSearchTerm.trim());
}, [debouncedSearchTerm]);
Expand All @@ -84,13 +86,13 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
},
);

const orderedOptions = orderOptions(optionList);
const orderedOptions = orderOptions(optionList, activePolicyID);

return {
...optionList,
...orderedOptions,
};
}, [action, areOptionsInitialized, betas, didScreenTransitionEnd, options.personalDetails, options.reports]);
}, [action, activePolicyID, areOptionsInitialized, betas, didScreenTransitionEnd, options.personalDetails, options.reports]);

const chatOptions = useMemo(() => {
if (!areOptionsInitialized) {
Expand All @@ -102,12 +104,12 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
headerMessage: '',
};
}
const newOptions = filterAndOrderOptions(defaultOptions, debouncedSearchTerm, countryCode, {
const newOptions = filterAndOrderOptions(defaultOptions, debouncedSearchTerm, countryCode, activePolicyID, {
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
});
return newOptions;
}, [areOptionsInitialized, defaultOptions, debouncedSearchTerm, countryCode]);
}, [areOptionsInitialized, defaultOptions, debouncedSearchTerm, countryCode, activePolicyID]);

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