Advantage and disadvantage is just rolling two dice at once. Advantage takes the higher roll and disadvantage takes the lower one. Criticals and failures are calculated after determining which die is used.
So with advantage, the only way to roll a one is to roll ones on both dice. The opposite is true for disadvantage. You need two 20s for a critical.
And they can cancel out if you have both; basically it becomes a regular roll. You also can’t have double advantage or disadvantage.
Criticals are either double damage or rolling damage dice twice.
I am fairly sure, this is not how if is implemented in the game. As I said before, if a critical miss on one dice doesn't overrule advantage rerolls, then to get a critical miss with advantage you would need to roll a 1 twice - this is a (1/20)*(1/20)=1/400 chance. It happens way way more frequently than that. Also critical hits do not double damage in my game - they do entirely normal damage, without even a bonus.
The advantage thing might be a UI problem I think, because it quite often tells me I have advantage but doesn't give me a second roll (actually, this might be related to the critical miss thing - if advantage is being cancelled but it doesn't show up in the UI). So maybe a disadvantage is cancelling it but it still shows as advantage.
Edit: I just saw this post:
https://forums.larian.com/ubbthreads.php?ubb=showflat&Number=759820#Post759820 It looks like the advantage/disadvantage UI is currently bugged/incorrect, so this may be the issue.