Database

[{"name":"Test User","history":[{"departmentName":"department1","active":false},{"departmentName":"department2","active":true},{"departmentName":"department3","active":false}],}]

Query

db.collection.aggregate([{$match:{"name":"Test User","history.active":true}},{$addFields:{history:{$filter:{input:"$history",cond:{$eq:["$$this.active",true]}}}}}])

Result