diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index 2e9b06f3d6..2c20b97fb2 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -573,12 +573,13 @@ router.post( teamId: teamFromCtx?.id, }); const isPublic = cannot(user, "read", document); - const serializedDocument = await presentDocument(ctx, document, { - isPublic, - shareId, - }); - - const team = await document.$get("team"); + const [serializedDocument, team] = await Promise.all([ + presentDocument(ctx, document, { + isPublic, + shareId, + }), + teamFromCtx?.id === document.teamId ? teamFromCtx : document.$get("team"), + ]); // Passing apiVersion=2 has a single effect, to change the response payload to // include top level keys for document, sharedTree, and team.