Baal Shem Tov-The proper reaction when witnessing another perform a transgression:
When one sees another Jew performing a transgression, or hears of such a transgression having been performed, one’s immediate reaction should be to try to find that sin within his soul. It may not be the exact sin in quantity and quality as that which was witnessed or heard of, however one is to search for a similar matter in his soul that corresponds in some way to that sin. The purpose of Hashem giving him the knowledge of this sin is to reveal to him that he can fix this aspect of his soul. When one goes ahead and repents for his corresponding sin it can then cause the original sinner to also repent. This can be accomplished through one intending to unite with the Rasha, and when he does so and repents, he helps initiate a movement of Teshuva within the person.
Maggid-How to react if one sees a sin transpire:
Man should be aware that whatever he witnesses contains a Divine intent. One who sees a sin transpire by another, has not been shown this sin for naught. Hashem showed him the sin as Divine providence to hint to him that he too is guilty of the sin on some level. Even if one knows that he never actually committed such a sin, perhaps he has contemplated this sin, and it is known that the thought of a sin is [in certain aspects] even more severe than the actual sin itself.
 Keser Shem Tov 89; Toldos Yaakov Yosef Lech Lecha 17a
 Or Torah [Maggid] Vayikra 107