import com.atlassian.jira.bc.user.search.UserSearchParams
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.component.ComponentAccessor
def userSearchService = ComponentAccessor.getComponent(UserSearchService)
final def limitValue = ''
//Build a search with 100,000 results where users are inactive
def userSearchBuilder = new UserSearchParams.Builder(limitValue)
def userSearchParams = userSearchBuilder.allowEmptyQuery(true)
.includeActive(false)
.includeInactive(true)
.limitResults(limitValue)
.build()
//Retrieve immutableList of Inactive Users
def inactiveUsers = userSearchService.findUsers('', userSearchParams)
//You can convert immutableList inactiveUsers, to a List with below
//which is useful for method like ProjectRoleService.removeActorsFromProjectRole()
def usersToRemove = [] as List
inactiveUsers.each {
usersToRemove.add(it.key.toString())
}