From what I researched online it is most dangerous in the first trimester but ok after that. Little research has been done to see if it crosses the placenta or not. It's also less safe with hair bleaching than it is for just dying it. I cam attest that I both bleached and dyed my hair multiple times during my first trimester with no Ill effects. But of course I'm just one person so idk how things might be for you.
There is little or no evidence of adverse effects from dyeing your hair while pregnant, but it also hasn't been studied much if at all. It is possible that there are risks, and likewise possible that it could be totally safe. These sort of recommendations tend to err on the side of caution though.