Skip to content

Commit bf27e9b

Browse files
authored
Merge pull request Expensify#67857 from allgandalf/fixInputDisplayForWorkflows
Fix: Search field is present in 'Authorized payer' RHP even when the list of employees is less than 8
2 parents 1c79249 + d32fc01 commit bf27e9b

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/pages/workspace/workflows/WorkspaceWorkflowsPayerPage.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,17 @@ function WorkspaceWorkflowsPayerPage({route, policy, personalDetails, isLoadingR
160160
[policy, isLoadingReportData],
161161
);
162162

163+
const totalNumberOfEmployeesEitherOwnerOrAdmin = useMemo(() => {
164+
return Object.entries(policy?.employeeList ?? {}).filter(([email, policyEmployee]) => {
165+
const isOwner = policy?.owner === email;
166+
const isAdmin = policyEmployee.role === CONST.POLICY.ROLE.ADMIN;
167+
return !isDeletedPolicyEmployee(policyEmployee) && (isOwner || isAdmin);
168+
});
169+
}, [isDeletedPolicyEmployee, policy?.employeeList, policy?.owner]);
170+
171+
const shouldShowSearchInput = totalNumberOfEmployeesEitherOwnerOrAdmin.length >= CONST.STANDARD_LIST_ITEM_LIMIT;
172+
const textInputLabel = shouldShowSearchInput ? translate('selectionList.findMember') : undefined;
173+
163174
return (
164175
<AccessOrNotFoundWrapper
165176
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
@@ -182,7 +193,7 @@ function WorkspaceWorkflowsPayerPage({route, policy, personalDetails, isLoadingR
182193
/>
183194
<SelectionList
184195
sections={sections}
185-
textInputLabel={translate('selectionList.findMember')}
196+
textInputLabel={textInputLabel}
186197
textInputValue={searchTerm}
187198
onChangeText={setSearchTerm}
188199
headerMessage={headerMessage}

0 commit comments

Comments
 (0)