activeOrganizationId is null

Hi, i've been running into an issue that i've been trying to debug for a couple days now. With the org plugin, activeOrganizationId on the session is (usually) null, causing getActiveMember to break too.

Adding the below to my auth config sometimes fixes it, but sometimes it inexplicably breaks (for some orgs specifically).
session: {
        create: {
          before: async (session) => {
            const member = await db.query.members.findFirst({
              where: (m, { eq }) => eq(m.userId, session.userId),
            });
            if (!member) {
              return undefined;
            }

            return {
              data: {
                ...session,
                activeOrganizationId: member?.organizationId,
              },
            };
          },
        },
      },


Anyone have an idea on how to fix this?
My auth config is here: https://gist.github.com/Badbird5907/5628d5f881bc57f9d70462bfe232307a

The users were created with a script directly inserting the users/orgs into their respective tables in the db, and the users use the google provider to log in.

Thanks
Was this page helpful?