const { get, includes } = require('lodash')

function filterActiveAdvisers ({ advisers = [], includeAdviser = [] }) {
  includeAdviser = [...includeAdviser]
  return advisers.filter(adviser => {
    // This returns all active users plus the include advisor (whether they are active or not)
    return (
      get(adviser, 'is_active', true) ||
      includes(includeAdviser, adviser.id)
    )
  })
}
module.exports = {
  filterActiveAdvisers,
}

const {
  get,
  includes,
  castArray,
  compact,
} = require('lodash')

function filterActiveAdvisers ({ advisers = [], includeAdviser }) {
  let adviserIds = compact(castArray(includeAdviser))
  return advisers.filter(adviser => {
    // This returns all active users plus the include advisor (whether they are active or not)
    return (
      get(adviser, 'is_active', true) ||
      includes(adviserIds, adviser.id)
    )
  })
}
module.exports = {
  filterActiveAdvisers,
}

Fix for when a user edits a Client Relationship Manager
Fix for when a user edits a Client Relationship Manager
