Sample documents for all you use-cases including:
Read Formatting code and log snippets in posts before supplying all documents we need to experiment.
Share exactly the code you
My approach would be to group on transaction_id using $addToSet for the status. Then a $match a $nin on the $addToSet array.