Well I’m just thinking that you may have had an error in the code since you got 500. That’s all.
Add this to theme’s functions.php. Worked for me. Added this for topics and replies. Check that you wouldn’t have a syntax error.
I added this feature to topics as well as replies. But selected state is not happening for me. No option has selected state. Anyone else has had this?