Sad to read of people throwing away perfectly good food because it's passed the 'use by' date.
Food poisoning is caused by toxins produced by active bacteria in the foodstuff.
From my long ago Food Hygiene lectures:
Bacteria need three conditions to become active:
Food
Moisture
Oxygen
If one of these is absent, they cannot become active. therefore cannot produce toxins. so things like flour and cocoa, dried pulses cannot harm you, however far past the 'use by' date they are.
Once all three conditions are present bacteria need warmth and time to multiply effectively. Which is why susceptible food is kept at a low temperature. And cooked or eaten soon, once out of the fridge. The longer it is kept at bacterias' ideal temperature the more active and toxic they become. Once the temperature rises above that they are destroyed. Advice on temperatures is readily available on line.
Bacterial action is obvious, bubbles, discolouration and, often, smell.
Use by/sell by dates on food are a legal requirement. I suspect that, for dried food particularly, producers have no idea how long it remains viable, but they have to put something... But they are the cause of dreadful amounts of food waste because people don't know the science. Unless you are actually allergic to a foodstuff it'll be bacterial toxins that will poison you. No bacterial action, no toxins...
Hope this helps