How often I think my current self is smarter than more former self, and that turns out not to be the case!  I now realize that I can't flatten the if/then hierarchies entirely because there are asynchronous calls involved.  So, hopefully, here's a compromise solution with some helper functions.