From bbe03bb83ddb3e2d14562d4c7199e17311513cd2 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 4 Aug 2026 17:29:31 +1000 Subject: [PATCH] feat: notify all members of the first signing group on send --- packages/lib/server-only/document/send-document.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/lib/server-only/document/send-document.ts b/packages/lib/server-only/document/send-document.ts index 1715739f7..361567856 100644 --- a/packages/lib/server-only/document/send-document.ts +++ b/packages/lib/server-only/document/send-document.ts @@ -38,6 +38,7 @@ import { isDocumentCompleted } from '../../utils/document'; import { extractDocumentAuthMethods } from '../../utils/document-auth'; import { type EnvelopeIdOptions, mapSecondaryIdToDocumentId } from '../../utils/envelope'; import { toCheckboxCustomText, toRadioCustomText } from '../../utils/fields'; +import { filterRecipientsInFirstSigningGroup } from '../../utils/recipient-groups'; import { getRecipientsWithMissingFields, isRecipientEmailValidForSending } from '../../utils/recipients'; import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id'; import { insertFormValuesInPdf } from '../pdf/insert-form-values-in-pdf'; @@ -150,10 +151,11 @@ export const sendDocument = async ({ id, userId, teamId, sendEmail, requestMetad let recipientsToNotify = envelope.recipients; if (signingOrder === DocumentSigningOrder.SEQUENTIAL) { - // Get the currently active recipient. - recipientsToNotify = envelope.recipients - .filter((r) => r.signingStatus === SigningStatus.NOT_SIGNED && r.role !== RecipientRole.CC) - .slice(0, 1); + // Get the currently active signing group. Recipients sharing the lowest + // pending signing order act in parallel within their group. + recipientsToNotify = filterRecipientsInFirstSigningGroup( + envelope.recipients.filter((r) => r.signingStatus === SigningStatus.NOT_SIGNED && r.role !== RecipientRole.CC), + ); } if (envelope.envelopeItems.length === 0) {