Bathroom fan and clothes dryer share an exhaust duct
The only good solution here is to run independent duct lines to the exterior, as should've been done initially. It's a violation of codes for good reason, as you've seen. Both ducts should be rigid or semi-rigid pipe, as appropriate.

Backflow preventers aren't the answer, because if multiple fans are running, and one is stronger, the other could be completely blocked. This means that the weaker fan isn't doing its job and may overheat due to lack of cooling airflow.