Database

[{type:"foo",value:2,hashedIdentifier:"ASDZXC",createdAt:ISODate("2022-02-27T14:17:44.860+00:00")},{type:"foo",value:2,hashedIdentifier:"ASDZXC",createdAt:ISODate("2022-01-27T14:17:44.860+00:00")},{type:"foo",value:2,hashedIdentifier:"ASDZXC",createdAt:ISODate("2022-01-19T14:17:44.860+00:00")},{type:"bar",value:3,hashedIdentifier:"TSSGKE",createdAt:ISODate("2022-02-28T15:17:44.860+00:00")},{type:"bar",value:3,hashedIdentifier:"TSSGKE",createdAt:ISODate("2022-01-27T15:17:44.860+00:00")},{type:"try",value:4,hashedIdentifier:"KSDFJS",createdAt:ISODate("2022-03-02T15:17:44.860+00:00")},]

Query

db.collection.aggregate([{$group:{_id:"$hashedIdentifier",latestExisting:{$max:"$createdAt"}}},{$match:{_id:{$in:["ASDZXC","TSSGKE","SDFKAR"]}}},{$group:{_id:0,existing:{$push:{hashedIdentifier:"$_id",latestExisting:"$latestExisting"}}}},{"$addFields":{"newItems":[{type:"foo",value:2,hashedIdentifier:"ASDZXC",createdAt:ISODate("2022-03-06T14:18:44.860+00:00")},{type:"bar",value:3,hashedIdentifier:"TSSGKE",createdAt:ISODate("2022-03-06T15:17:44.860+00:00")},{type:"newOne",value:9,hashedIdentifier:"SDFKAR",createdAt:ISODate("2022-03-06T15:17:44.860+00:00")}]}},{$unwind:"$newItems"},{$project:{existing:{$filter:{input:"$existing",as:"item",cond:{$eq:["$$item.hashedIdentifier","$newItems.hashedIdentifier"]}}},newItems:1,latestExisting:1}},{$project:{existing:{$arrayElemAt:["$existing",0]},newItem:"$newItems"}},{$project:{delta:{$subtract:["$newItem.createdAt","$existing.latestExisting"]},latestExisting:1,newItem:1}},{$match:{$or:[{delta:{$gte:604800000}},{delta:null}]}},{$replaceRoot:{newRoot:"$newItem"}},{$merge:{into:"collection"}}])

Result