Hi!
“What were we thinking going to lunch?”
I actually have a bit of a different answer. This sentence can be used when you accidentally went to lunch in error and made some form of mistake.
I believe it is grammatically correct and used mostly in spoken conversation.
For example, if a few colleagues accidentally went out to lunch during a time when an important meeting is scheduled that they had overlooked. When they realize, they might state to one another, “what were we thinking going to lunch?”