Asalamualaykum, if a friend tells a haram joke against Allah, I feel like I am about to smile at that joke, but I try my best to stop myself and ignore him.
How do I prevent myself from smiling at these haram jokes? Is this haram?
Work on strengthening your own iman and ghayrah, having to supress smiles on haram jokes is not the trait of a Muslim.Would you have to supress a smile if someone made a joke about your mother? Or would you have to supress the urge to break his teeth? Read sira of the sahaba see how they reacted.
Secondly, don't have such friends in the first place:
O you who have believed, take not those who have taken your religion in ridicule and amusement among the ones who were given the Scripture before you nor the disbelievers as allies. And fear Allah, if you should [truly] be believers.
And it has already come down to you in the Book that when you hear the verses of Allah [recited], they are denied [by them] and ridiculed; so do not sit with them until they enter into another conversation. Indeed, you would then be like them. Indeed Allah will gather the hypocrites and disbelievers in Hell all together -
If you think Allah as your closest friend, you can play with him, laugh with him, laugh on jokes on him, this only makes the bond stronger with Him.
Love doesn't ties you, rather it makes you free. If you feel laughing at jokes on Him and YOU ARE WORRIED ABOUT IT, that only means you fear Him.
But if you accept Him as your friend, you will just realise what type of jokes you should laugh at and what not. Forget the rulebook.
For realising that He is always with you, try talking with Him, after some practice, you will get answers to your every questions just magically whenever you ask.