From 9d86052ff514c9463a8a25b52cdcfe82180728b9 Mon Sep 17 00:00:00 2001 From: Michael Sukkarieh Date: Fri, 13 Jun 2025 17:22:57 -0700 Subject: [PATCH] Delete account join request when redeeming an invite (#352) * delete account join request when redeeming an invite * fix account request fetch --- packages/web/src/actions.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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)) {