If most of the food that was given to the fish was taahir (pure), it is permissible to eat the fish and there is nothing wrong with that.
But if most of it was from najis (impure) carcasses (i.e., the fish are what the scholars call jallaalah or animals that feed on filth), then it is not permissible to eat the fish until they have been prevented from eating impurities for three days or more, and have been fed with food that is pure so that their flesh will become good.
It says in Kashshaaf al-Qinaa‘ (6/193): Jallaalah – which refers to animals most of whose food is najis – is haraam, as is its milk, because of the report narrated by Ibn ‘Umar who said: The Prophet (blessings and peace of Allah be upon him) forbade eating jallaalah or (drinking) its milk. Narrated by Ahmad, Abu Dawood and at-Tirmidhi who said: (it is) hasan ghareeb. It was classed as saheeh by al-Albaani in al-Irwaa’, 2503…
… (it is haraam) until it has been kept for three days and nights, because if Ibn ‘Umar wanted to eat (such an animal), he would keep it for three days and feed it with pure food, and prevent it from eating impure food, whether it was a bird or animal, because the factor that was preventing it from being halaal would be removed thereby. End quote.
Shaykh al-Islam Ibn Taymiyyah said: The milk of the jallaalah that feeds on impure things was forbidden by the Prophet (blessings and peace of Allah be upon him), but if it is kept until it becomes pure, then it becomes halaal according to Muslim consensus, because before that the traces of impurity would appear in its milk, eggs and sweat, and the stench and foulness of the impurity would become apparent. But once that disappeared it would become pure. If the ruling applies because of a reason, it ceases to apply when that reason disappears.
End quote from Majmoo‘ al-Fataawa, 21/618.
The Standing Committee for Issuing Fatwas was asked: They feed chickens with various kinds of food, among which is ground meat of animals that died without being slaughtered properly, and meat from pigs. Are the chicken that are fed with this meat halaal or haraam? If they are haraam, what is the ruling on their eggs?
They replied: If what is said about their feed is correct, then there is a difference of opinion among the scholars with regard to eating their flesh and eggs. Maalik and a number of others said that eating their flesh and eggs is permissible, because the impure feed becomes pure when it is transformed into flesh and eggs (i.e., istihaalah). But a number of scholars, including ath-Thawri, ash-Shaafa‘i and Ahmad are of the view that it is haraam to eat their flesh and eggs, or to drink the milk (of animals to which the same criteria apply), unless they were fed with pure feed after that for three days or more, in which case it becomes permissible to eat the (meat), eggs and milk. And it was said that if most of their feed is impure, then they are classed as jallaalah and cannot be eaten, but if most of their feed is pure, then they may be eaten. A number of scholars said that it is haraam, because of the report narrated by Ahmad, Abu Dawood, an-Nasaa’i, at-Tirmidhi and Ibn Maajah from Ibn ‘Umar, according to which the Messenger of Allah (blessings and peace of Allah be upon him) forbade eating jallaalah or (drinking) their milk.
Jallaalah refers to any animal that eats filth and other kinds of impurities. But the most correct view is that which says that it depends, which is the second view quoted above.
End quote from Fataawa al-Lajnah ad-Daa’imah, 23/377
If it is clear that eating these fish – even if they have been kept (away from impurities) for three days or more – will cause harm, it is not permissible to eat them, because Allah, may He be exalted, says (interpretation of the meaning): “and do not throw yourselves into destruction” [al-Baqarah 2:195]. And the Prophet (blessings and peace of Allah be upon him) said: “There should be no causing harm or reciprocating harm.” Narrated by Ibn Maajah, 2431; classed as saheeh by al-Albaani in Irwa’ al-Ghaleel, 896
And Allah knows best.