You can start with initial filtering using $in and then to map all the values from input array into final result you have to $group them $push-ing $$ROOT (enitre document), then you can just merge input usernames with docs using $map and $filter operators:
db.col.aggregate([
{
$match: { username: { $in: ['user1', 'user2', 'user3'] } }
},
{
$group: {
_id: null,
docs: { $push: "$$ROOT" }
}
},
{
$project: {
_id: 0,
results: {
$map: {
input: ['user1', 'user2', 'user3'],
as: 'username',
in: {
$let: {
vars: {
filtered: {
$filter: {
input: "$docs",
as: "doc",
cond: { $eq: [ "$$doc.username", "$$username" ] }
}
}
},
in: {
$arrayElemAt: [ "$$filtered", 0 ]
}
}
}
}
}
}
}
])
Mongo playground