Anna P. answered 01/20/25
Adjunct Assistant Professor with 15+ years teaching experience
Disclamer: Do not eat nightshade berries! Especially if you don't have identification experience, as there are look alike berries and not all nightshades act the same.
Solanine does degrade with heat, but it has to be at a certain heat (170oC or more) for a specific amount of time. The time needed depends on the volume being cooked. Solanine can also be leeched out with an acid like vinegar.
Solanum dulcamara is not as toxic as some other nightshade group plants like belladonna once the berries are ripe, but they still contain some solanine. There is some risk in consuming them, even when cooked.
Considering the story, I would guess the berries in the pie were cooked for a good long time before baking and likely with special preparation steps that included soaking in some kind of acidic liquid (vinegar, lemon juice, etc.). That family likely had a cultural/family recipe that was tested over generations to help improve chances of making it safe. Also, if it was only eaten once a year, that also reduced chances of toxin dosage reaching lethal levels.