The current code get all boards and look at their attached project to pick one.
Jira Server doesn't expose this information and, actually, there is a more efficient way to do it because there is a search that allows to do this filter. The filter works also with Jira Cloud.