I think grammar is based on general, situational, and everyday contextual speech patterns. Written context also plays a part in this as well, of course. I don't think it is so much that the brain is wired for grammar, but...
I'm not a teacher, so please consider any advice I give in that context.
they talked about what needed doing.
q. which sentence it is?