Two minor pieces are generally stronger than a rook, with the advantage becoming more evident when the game heads to the endgame.
It is clear that there can be exceptions even in an endgame, like one of the two minor pieces being misplaced (a "bad bishop" may lead to such a situation) or a situation where the two minor pieces are temporary unable to parry some direct threat, like the rook being able to capture a few pawns before the two minor pieces have the time to regroup.
While the game is still in the middlegame situations can be very fluid and depend on many independent variables: open files, pawn structures and so on. In any event it is impossible--and unwise--to generalize from one single game or position.
It is likewise difficult to suggest when is convenient to give up a Rook for lesser material. That's more so for the possibly more classical of all middlegame sacrifices: the sacrifice of the exchange. Under the right circumstances a well placed bishop or even a well placed knight may be worth, dinamically speaking, a rook and may give their side a lot of compensation for the material loss.
Yet, one has to consider that average-goodish players do not often have the necessary technique to turn these dinamic advantages into more concrete and lasting ones, so they have to be considered temporary and the learning chessplayer needs to be extra-careful about exchange sacrifices because even if they are good in an abstract "ideal" sense, they might turn out to be poor choices.