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.
If there is some oil or any other thing that prevents water from reaching the roots of the hair, it should be removed by shampoo or any other detergent.
In fact, water must touch the skin of the head in Janaabah Ghusl (ceremonial bath) as washing the whole head is an obligation in Ghusl.
Allah knows best.