Double 'where' clause in dynamic query overriding the original 'where' clause not combining

Hi I am using Drizzle to fetch some records:

    const query = db
        .select({
            // some fields
        })
        .from(leads)
        .innerJoin(participants, eq(participants.id, leads.participantId))
        .innerJoin(
            organizations,
            eq(organizations.id, participants.organizationId)
        )
        .innerJoin(campaigns, eq(campaigns.id, leads.campaignId))
        .leftJoin(agents, eq(agents.id, leads.agentId))
        .leftJoin(sites, eq(sites.id, leads.siteId))
        .leftJoin(studies, eq(studies.id, leads.studyId))
        .where((t) => {
            // ... a bunch of conditions
        })
        .orderBy(desc(leads.updatedAt))
        .$dynamic();


and I want to do an additional level of filtering as well later in the function like so:

await query.where(inArray(participants.id, searchResults)))

However these results now don't still have the original filters from the where clause in initial dynamic query? Is this intentional and how do I fix it?
Was this page helpful?