I think the real unwritten rule is, don't flirt with someone unless you're reasonably confident that they'd like to be flirted with. Some people might be able to figure that out in a matter of minutes, and others might need to get to know someone over the course of weeks or months in a casual group setting to figure it out.
I am sorry to say, but I think people who believe flirting is not allowed probably have not put in the effort to be able to read social cues, don't have an aptitude for it, or never learned to flirt in a non-offputting way.