Skip to content

Commit 2fc6200

Browse files
committed
fix: consider expense.HostCollectiveId
1 parent 7603413 commit 2fc6200

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/graphql/common/comment.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ async function assertExpenseIsNotFulfilled(comment: Comment, remoteUser?: User):
169169
if (comment.ExpenseId) {
170170
const expense = await Expense.findByPk(comment.ExpenseId);
171171
if (expense && EXPENSE_LOCKED_STATUSES.includes(expense.status as ExpenseStatuses)) {
172-
const collective = await models.Collective.findByPk(expense.CollectiveId);
173-
if (collective?.HostCollectiveId && remoteUser?.isAdmin(collective.HostCollectiveId)) {
172+
const hostCollectiveId =
173+
expense.HostCollectiveId ||
174+
(await models.Collective.findByPk(expense.CollectiveId).then(c => c.HostCollectiveId));
175+
if (hostCollectiveId && remoteUser?.isAdmin(hostCollectiveId)) {
174176
return;
175177
}
176178
throw new ValidationFailed(

0 commit comments

Comments
 (0)