I don't know the grammar of "when who should we run into but Dan". How does "who should ~" come after "when"? Could you explain the grammar of this sentence?
"When who should we run into but (someone)" is an idiom, so it is not grammatically correct (not all idioms are grammatically incorrect, but many are). This idiom is used to describe unexpectedly seeing someone, which is what "run into" refers to. Ex: I was on a hike, when who should I run into but my first grade teacher! Ex: My mom and I were shopping, when who should we run into but my mom's boss.