diff --git a/packages/web/src/actions.ts b/packages/web/src/actions.ts index 9f60373a..6481624d 100644 --- a/packages/web/src/actions.ts +++ b/packages/web/src/actions.ts @@ -1147,6 +1147,25 @@ export const redeemInvite = async (inviteId: string): Promise<{ success: boolean } }); + // Delete the account request if it exists since we've redeemed an invite + const accountRequest = await tx.accountRequest.findUnique({ + where: { + requestedById_orgId: { + requestedById: user.id, + orgId: invite.orgId, + } + }, + }); + + if (accountRequest) { + logger.info(`Deleting account request ${accountRequest.id} for user ${user.id} since they've redeemed an invite`); + await tx.accountRequest.delete({ + where: { + id: accountRequest.id, + } + }); + } + if (IS_BILLING_ENABLED) { const result = await incrementOrgSeatCount(invite.orgId, tx); if (isServiceError(result)) {