Mongo Playground

Configuration

[{"_id":{"$oid":"61f1cdd07018c60012b3dd09"},"expenses":[{"category":"61eafc104b88e154caa58616","price":"1111.00"},{"category":"61f1cdb87018c60012b3dd07","price":"2222.00"},{"category":"61f1cda47018c60012b3dd01","price":"1241.00"},{"category":"61f1cdb87018c60012b3dd07","price":"111.00"}],"userId":"61eab3e57018c60012b3db3f"}]

Query

db.collection.update({"expenses.category":{$in:["61f1cda47018c60012b3dd01","61f1cdb87018c60012b3dd07"]}},{$set:{"expenses.$[elem].category":"61eab3e57018c60012b3db3f"}},{arrayFilters:[{"elem.category":{$in:["61f1cda47018c60012b3dd01","61f1cdb87018c60012b3dd07"]}}]})

Result