Addresses the issue flagged by @palys-swm here: https://phabricator.ashoat.com/D3702?id=11317#inline-22176
I tried a few other ways to do this, but ran into various flow issues. This aproach works, but it seems overly complex. Will continue investigating alternative approaches.