Skip to content

Commit

Permalink
fix: only collectives user admins can be picked when editing expense
Browse files Browse the repository at this point in the history
  • Loading branch information
kewitz committed Nov 15, 2024
1 parent 8328c49 commit c7c58a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 11 additions & 4 deletions components/expenses/ExpenseFormPayeeStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,23 @@ const ExpenseFormPayeeStep = ({
customOptionsPosition={CUSTOM_OPTIONS_POSITION.BOTTOM}
getDefaultOptions={build => values.payee && build(values.payee)}
disabled={disablePayee}
invitable
invitable={!editingExpense}
onInvite={onInvite}
LoggedInUser={loggedInAccount}
includeVendorsForHostId={collective.host?.legacyId || undefined}
addLoggedInUserAsAdmin
excludeAdminFields
searchQuery={expenseFormPayeeStepCollectivePickerSearchQuery}
filterResults={collectives =>
collectives.filter(c => c.type !== CollectiveType.VENDOR || c.hasPayoutMethod)
}
filterResults={collectives => {
if (editingExpense) {
return collectives.filter(c =>
loggedInAccount.adminMemberships?.nodes.some(m =>
[c.slug, c.host?.slug].includes(m.account.slug),
),
);
}
return collectives.filter(c => c.type !== CollectiveType.VENDOR || c.hasPayoutMethod);
}}
loading={loading}
/>
)}
Expand Down
4 changes: 4 additions & 0 deletions lib/graphql/v1/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ export const expenseFormPayeeStepCollectivePickerSearchQuery = gqlV1/* GraphQL *
isActive
isArchived
isHost
host {
id
slug
}
payoutMethods {
legacyId: id
type
Expand Down

0 comments on commit c7c58a4

Please sign in to comment.