Ruling on wearing shoes or socks that cover the ankles when in ihram, when one has valid reason
Question

I have plans to do Hajj in the future. I have a problem, my feet are flat. I cannot walk without orthopedic insoles. How can I do the Tawaf? What can you advise and suggest to me? What are all the solutions allowed ? For example, new sandal(or new shoes...) with othopedic insoles only to use in interior of the masjeed/mosque (and to walk at Mina-safa... ) or sock with orthopedic soles, etc .....?
Praise be to Allah.Firstly:
It is haram for the pilgrim in ihram for Hajj or ‘umrah to wear khuffs or anything that covers the ankles, such as socks, some kinds of athletic shoes, and so on. But there is nothing wrong with wearing flip-flops, sandals or shoes that come below the ankles.
The basic principle regarding that is the report narrated by al-Bukhari from ‘Abdullah ibn ‘Umar (may Allah be pleased with him), who said: A man stood up and said: O Messenger of Allah, what clothes do you instruct us to wear in ihram? The Prophet (blessings and peace of Allah be upon him) said: <<Do not wear a chemise or trousers or turban or burnoose; and if someone does not have shoes, let him wear khuffs and cut them so that they come lower than the ankles. And do not wear anything that has been dyed with saffron or wars (a yellow plant dye), and the woman in ihram should not wear a face veil or gloves.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said in Sharh al-‘Umdah (3/35): Once he has cut down the khuffs they become like shoes and once he has torn the seam of trousers they become like an izar (waist-wrapper or lower garment), then they can no longer be called khuffs or trousers. Hence when it is said: Wipe over the khuffs, and it is permissible to wipe over the khuffs, and he instructed us not to take off our khuffs, this does not include those that are cut or sandals. It is not known in regular linguistic usage that what has been cut down, or sandals and the like, can be called khuffs.
Hence it says in the hadith: “Let him put them on and cut them until they come lower than the ankles.” He called them khuffs before they are cut, and issued instructions that they be cut. This is like saying tear the seam of trousers to turn them into an izar, and turn the chemise into a rida’ (upper garment). It is well known that these things can only be called a chemise or trousers before their seams are torn. Thus it is known that what has been cut is no longer called a khuff, unless it is called a “cut khuff”, just as one may say “a torn chemise” after its seam has been torn and it is no longer called a chemise or trousers. Similarly, in the case of a dead animal (haywan), after it has died it is no longer an animal, because in fact the haywan (animal) is that in which there is life (hayat)…
In this situation, the Prophet (blessings and peace of Allah be upon him) instructed that the pilgrim should put on the khuffs [and cut them], and footwear that comes below the ankle is not called khuffs, so it is not appropriate to interpret the Prophet’s words as referring to khuffs, let alone stipulating that he must wear khuffs.
And he said (3/45): We have noted above that in the hadith of Ibn ‘Umar, the Prophet (blessings and peace of Allah be upon him) did not give a concession allowing the wearing of pants or khuffs, rather he gave this concession after ‘Arafah. Thus it is known that his words “let him wear the khuffs and cut them so that they come below the ankles” are explaining what it is permissible to wear, and that it is no longer regarded as khuffs, which are prohibited, as they have become like shoes which are permissible. Otherwise, there would be no difference between wearing them when they are cut and when they are intact. That concession is granted to the one who cannot find shoes, because of the reason mentioned above. Then he granted a concession after that allowing one who cannot find anything else to wear khuffs and trousers. Thus the khuffs that have been cut and the pants that have been torn are permissible to wear in all cases.
Moreover, the Prophet (blessings and peace of Allah be upon him) only forbade the pilgrim in ihram to wear khuffs, as he granted a concession allowing wiping over the khuffs, and whatever comes below the ankle, such as shoes and the like cannot be called khuffs and is not like khuffs, so it is not included in the prohibition. Similarly, it is not included in the permission to wipe over them, especially when his prohibition on wearing khuffs means that other types of footwear are permissible, because he was asked about what garments the pilgrim in ihram may wear, and he said: He may not wear such and such. Thus he mentioned only what is prohibited, so what he did not mention is permissible…
The foot is a limb that needs to wear something, so what it needs must be permissible. Many people cannot walk in sandals, so there must be a concession allowing them to wear something similar to shoes and the like. This is in contrast to the hand, which is not usually covered with gloves and the like, because there is no need for that. End quote.
Secondly:
If you need to wear something – shoes or socks – that covers the ankle in order to use orthotics or inserts, there is nothing wrong with that, but you have to offer a fidyah.
The fidyah in this case is feeding six poor persons, giving each one half a saa‘ [of foodstuff], or fasting for three days, or slaughtering a sheep [and distributing its meat to the poor of the Haram]. The pilgrim may choose whichever of these three he wishes.
Shaykh Zakariyya al-Ansari (may Allah have mercy on him) said in Asna al-Matalib (1/507): Whoever wears in ihram something that it is haram to wear,  or he covers something that it is haram to cover, because of a need due to heat, cold, medical treatment, and the like, that is permissible, but he must offer a fidyah. End quote.
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said: There are three scenarios with regard to one who does things that are prohibited whilst in ihram.
The first scenario: he does what is prohibited unnecessarily and with no excuse. In this case, he is sinning and he must offer a fidyah.
The second scenario: he does that because he needs to. In this case he is not sinning, but he has to offer a fidyah. So if he needs to cover his head because of cold or heat from which he fears harm, it is permissible for him to cover his head, and he must offer a fidyah.
The third scenario: he does that but is excused because he was unaware of the ruling, or because he forgot, or was forced to do it, or was asleep. In that case there is no sin on him, and he does not have to offer a fidyah."(Majmu‘ Fatawa wa Rasa’il al-‘Uthaymin  24/433).
There is nothing wrong with walking in these shoes when doing sa‘i or tawaf, so long as they are clean.
And Allah knows best.