All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
There is nothing wrong with a Junub (a person in a state of major impurity) person in dyeing his hair before he performs Ghusl (ritual bath) and the dye does not affect the validity of Ghusul from Janabah, because it is just a color that has no mass, just like henna.
Mawahib al-jalil by Hattab Almaliki reads: “Imam Malik was asked about a menstruating and Junub woman dyeing her hands? He said, "Yes, and that is why women were keen on using it because their dyes would not break the purity for the prayer.”
Ibn Rushd said: ‘There is no doubt in its permissibility and there is no view that it is disliked, because the color of the dye that is applied in her hands does not prevent the removal of the state of Janabah and menstruation if she performs Ghusl. Ibn Naji said in explaining the al-Mudawwanah: “It is agreed (among the scholars) that the Henna (dye) is not something that prevents the water from reaching the skin.” [End of quote]
The importance is that the prayer time does not pass unless one performs what Allah has imposed on him to do, like Ghusl and prayer.
Allah knows best.