In most cases, the main verb takes the second position in the sentence and the rest of the verbs are at the end. Here 'gehen' is the main verb so it takes the second position. 'Essen' then, must go to the end.
There is a problem with Duolingo.
If I make certain mistakes, it doesn't correct me. In this case, I wrote "Ich gehe mit meinen Freunden esser" (I should wrote essen).
Duolingo accepted the answer without correcting the word.