Tales of poppy seed-covered foods being the cause of failed drug tests is a classic urban legend that's been floating around since a certain episode of Seinfeld. While there may be some truth behind the myth, poppy seeds aren't likely to ruin your drug test anymore.
In this video from the SciShow YouTube channel, Olivia Gordon explains the science of poppy seeds, opiates, and typical drug screening tests. If you weren't aware, morphine and other opiates come from the same plant as poppy seeds: Papaver somniferum, or the opium poppy. So, it's possible that poppy seeds — like you'd find on a bagel or in a muffin — carry the same chemical components as the opiates drug tests typically look for. However, the truth is the trace amounts of opiates that may have ended up on those poppy seeds don't come anywhere close to the amount in an actual dose of morphine or other hard opiates.
Urine tests are pretty sensitive, and those poppy seeds from your breakfast might show up, but it won't be enough to raise a red flag. Furthermore, the threshold for opiates found in urine was raised back in the early 2000s from .3 micrograms per milliliter to 2 micrograms per milliliter, which is a massive gap. If you're really worried about it, avoid consuming poppy seeds for a few days before your test. But don't sweat it if you had a tasty poppy seed muffin that morning either.