Praise be to Allah.
What that man told you about it being permissible for you to marry this girl without the knowledge of her wali is in accordance with the madhhab of Imam Abu Haneefah (may Allah have mercy on him), but it is contrary to the correct view and the view of the majority of the scholars, who stipulate that the guardian must be present and give his consent in order for the marriage contract to be valid.
But if there is a country whose people follow the madhhab of Imam Abu Haneefah (may Allah have mercy on him), then it may be ruled that marriage contracts that they do without the presence or consent of the girl’s guardian are valid. Please see a discussion of that in fatwa no. 132787.
The same applies in the case of one who gets married without the presence of the girl’s guardian, believing that this is valid – as in your case, when you went ahead with your marriage on the basis of a fatwa issued by a scholar. Therefore it is to be ruled valid. That has been discussed previously in fatwa no. 125363.
Thus you will realise that your divorce of your wife was a valid divorce that basically counts as such, because you divorced your wife after a marriage which you both believed to be valid.
But it remains to discuss the fact that it happened when she was menstruating, and whether it counts as three or one talaaq.
The fatwa that we follow states that divorce issued at the time of menstruation does not count as such, and does not count as one or more. If the husband issued three divorces at once, then it counts as one divorce.
You also say that some time after the divorce, you regarded this divorce as valid and took her back on that basis. Therefore this divorce counts as such, and constitutes one divorce.
With regard to your taking her back, if that was during the ‘iddah then it was a valid taking back, but if it was after the end of the ‘iddah, it is not valid, because at that point your wife had become completely divorced from you.
Rather the ruling is like that because the leading scholars stated that if a man divorces his wife by means of an innovated divorce (talaaq bid‘i) – such as a divorce issued at the time of menstruation – then he regarded it as valid, based on his own opinion, or following the opinion of a scholar who says that it counts as such, then it is to be counted as a divorce, especially since there is such a strong difference of opinion regarding this matter, and the majority of scholars say that the innovated divorce counts as such.
This has been discussed previously in fatwa no. 158115
It should be understood that the ‘iddah of a divorced woman is three menstrual cycles. When the third menstrual cycle ends, then her ‘iddah has ended. The husband cannot take her back except within the ‘iddah period only, because Allah, may He be exalted, says (interpretation of the meaning): “And their husbands have the better right to take them back in that period” – i.e., within the ‘iddah period – “if they wish for reconciliation” [al-Baqarah 2:228].
Thus Allah, may He be exalted, gave the husbands of divorced women a greater right to take them back during the ‘iddah period, if their intention by taking them back is reconciliation.
With regard to the second divorce that you issued to her three or four months later – as you said – if your taking her back was valid, because it occurred within the ‘iddah period, then this divorce counts as such. In that case you would have issued two divorces to her, so you may take her back so long as the ‘iddah period has not ended, and there remains for you the third divorce.
But if your taking her back (after the first divorce) was not valid, because it happened after the end of her ‘iddah, then this second divorce is worthless and does not count, because once the woman’s ‘iddah following divorce has ended, she is completely divorced from her husband, so any divorce or zihaar issued by him has no effect on her, because with the end of her ‘iddah she became a stranger (non-mahram) to him.
It says in Fiqh as-Sunnah (2/252) by Sayyid Saabiq (may Allah have mercy on him):
If a man says to a woman to whom he was not previously married, “You are divorced”, his words are meaningless and do not have any consequences. The same ruling applies to one who has been divorced and her ‘iddah has ended, because with the end of her ‘iddah she has become a stranger to him. End quote.
In this case, if you want to marry her again, then it is permissible for you to do that, with a new marriage contract and mahr, and in the presence and with the consent of her wali.
And Allah knows best.