Had this happen a few times now.
Party in an upgraded quest slot hasn't been collected yet, but is flagged as "ready" instead of "completed" in error on the party pick screen.
If I then try to add them to a party it does throw up the error you fortunately added to that "# this should never happen" code branch.
After collecting the party from the quest slot, they can be added to a new party as normal.
(No injuries in that party, so not caused by odd shenanigans such as hitting "heal all" for a party that had already healed from the upgraded quest slot...)