Sure, electro-optical sensors will be obscured by clouds, but that's why there are other sensors such as radar, which isn't.
Unit 3. Atmospheric Effects on Electro-optics
Clouds will have an impact on IR signatures, since clouds themselves are good at absorbing and emitting thermal energy, the fidelity of modern IR signatures is significant enough to filter this natural source of IR though - similar to how IR missiles track an aircraft dropping flairs and how they don't track the sun (anymore, the early AIM-9 had a problem with this).
Clouds & Radiation Fact Sheet : Feature Articles
Depends on the part-per-million count, but typically clouds aren't made of diesel fuel, so their PPM ratios tends to be low enough that hydro-carbon detectors aren't tripped up by them. The Earth's atmosphere has a lot of hydro-carbons in it, but not all of those match what is use on DE submarines, MPA crews are trained to ascertain specific signatures and discard others (the same way they are trained not to response to natural EM disturbances such as wildlife or underwater volcanoes).
So you want to detect a submarine?
There's a reason more than one type of sensor is used on the P-8. Remote sensing - sensors capable of peering through obstructions like clouds, smoke or even Earth (as noted on ground penetrating radar), supplement other, non-penetrating sensors to make for a complete package.
Principles of Remote Sensing - Centre for Remote Imaging, Sensing and Processing, CRISP
it's also worth noting that the higher one goes, the less effective MAD detection becomes, thus the P-8I and P-8A need other sensors if they wish to remain "off-the-deck"