All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
We do not know of any hadeeth indicating that one's prayer is cancelled (invalidated) because he harms others. However, it has been reported that whoever harms others will be thrown into Hellfire even if he observes prayers and fasting. Abu Hurayrah narrated that the Prophet was asked, "O Messenger of Allaah! A certain woman prays at night and fasts in the day but she harms her neighbors with her tongue." He Messenger of Allaah said, "There is no good in her; she is one of the people of the Hellfire." [Ahmad and Al-Haakim]
However, harming people does not entail deeming prayers invalid; i.e. it does not mean that this woman was not rewarded for her deeds. Rather, perhaps she has earned the reward but will not benefit of it because her reward will be given to those whom she harmed with her tongue. It has been reported that the Prophet said, "Do you know who is the bankrupt?" They (the Companions) said, "The bankrupt among us is one who has neither money nor belongings." He said, "Verily, the bankrupt of my Ummah (community) will be he who will come on the Day of Resurrection with prayers and fasts and zakah, but he had hurled abuses upon some people, defamed some, unlawfully consumed the wealth of some, shed the blood of some, and beat some, so his rewards will be credited to the account of each of them (who suffered at his hand). And if his good deeds fall short to clear the account, then their sins will be entered in his account and he will be thrown in the Hellfire." [Muslim and Ahmad]
As for your laughter at what the teacher or your friend said, it does not constitute kufr because you were not laughing at what you believed to be part of the Quran or the Sunnah. Also, this teacher, if he is Muslim, is not judged to be a disbeliever by merely saying what he said because he, based on what is apparent, did not intend to ridicule the obligation of jihaad. Needless to say, takfeer (declaring a Muslim individual or group to be non-Muslim) is a serious and grave matter. It is impermissible for the Muslim to hasten to label his fellow Muslims disbelievers merely based on such remarks. For more benefit, please refer to fatwa 721.
Allaah knows best.