The problem is always the same. At what point can we decide between physical welfare and emotional welfare? Clearly this child was physically far better off in her middle-class foster home, and there are those who would say that this should be the only concern of social services, etc. But she loved her dad and wanted to be with him, regardless of the poorer physical circumstances and potential abuse. At the very least, you ensured that there was some contact.
I'm far more ruthless than you. My engagement with my elderly parents concentrates almost totally on their physical welfare. That extends to separating them after 65 years of marriage because nowhere offers the different kinds of care they both require simultaneously. The emotional consequences of this are not within my remit or competence, given that neither of them was ever emotionally available to me when I needed them.
Of course, if I'm honest, I must admit that I have long been disinclined to donate an airborne copulation for my mothers' condition, either physical or mental. Nevertheless, I remain responsible fro them and will continue to discharge that responsibility as long as required.