Is it true that if someone is on medication for herpes it isn’t transmitted during unprotected sex?

Ive heard this and it just came up in convo w my friend and I’m wondering how it works?