feat: scope assistants to strictly later signing steps

This commit is contained in:
David Nguyen
2026-08-04 17:33:05 +10:00
parent 129833d6bb
commit 19514b182b
2 changed files with 13 additions and 6 deletions
@@ -23,9 +23,13 @@ export const getRecipientsForAssistant = async ({ token }: GetRecipientsForAssis
let recipients = await prisma.recipient.findMany({ let recipients = await prisma.recipient.findMany({
where: { where: {
envelopeId: assistant.envelopeId, envelopeId: assistant.envelopeId,
signingOrder: { OR: [
gte: assistant.signingOrder ?? 0, // The assistant themself — they may have fields of their own.
}, { id: assistant.id },
// Grouped assistants only assist strictly later steps, never their
// own group peers.
{ signingOrder: { gt: assistant.signingOrder ?? 0 } },
],
}, },
include: { include: {
fields: { fields: {
@@ -44,10 +44,13 @@ export const signEnvelopeFieldRoute = procedure
signingStatus: { signingStatus: {
not: SigningStatus.SIGNED, not: SigningStatus.SIGNED,
}, },
signingOrder: {
gte: recipient.signingOrder ?? 0,
},
envelopeId: recipient.envelopeId, envelopeId: recipient.envelopeId,
OR: [
// The assistant's own fields.
{ id: recipient.id },
// Fields of recipients in strictly later steps only.
{ signingOrder: { gt: recipient.signingOrder ?? 0 } },
],
} }
: { : {
id: recipient.id, id: recipient.id,