PullRequestEventListener.onPullRequestUpdated checks for target branch changes, but it doesn't check whether the pull request is open or not. Participants can only change their status on open pull requests.
There are two considerations here, really: 1. Target branch changes on declined pull requests shouldn't trigger exceptions, but... 2. Changing the target branch should still trigger unapproval
Since both of these aren't possible (participants cannot change their status on declined pull requests, which is enforced by the system and unlikely to change), perhaps the best approach is: * Ignore target branch changes on declined pull requests * Withdraw any approvals when a pull request is reopened after having been declined
It's not possible to check for a target branch change after the fact, so unapprove-on-reopen would have to just be a fixed behavior.