The five card hand must beat the two card hand, and both hands must beat the dealer's two hands in order to win.
The five cards have to beat the two cards but none of it matters if the dealer wins instead.