TT #396 · Parashas Shoftim · Seventh Aliyah · Passuk 21:09
And you shall purge the innocent blood from your midst, when you do what is right in the eyes of the Eternal.
Torah Temimah points to Sotah 47a / Sifrei.
TT lemma: כִּי תַעֲשֶׂה הַיָּשָׁר בְּעֵינֵי ה׳.
English: ‘When you do what is right in the eyes of the Eternal’ – this is the quality of uprightness.
Derash on the moral condition (Bavli / Sifrei) — the rite is effective when the people pursue what is right.
The innocent blood is purged from the midst of Yisrael when the people do what is right in the eyes of Hashem.