Seeking feedback on how to further simplify the code snippet below or if this is the most efficient approach. The goal is to add action.payload to the roles array if it's not already included, and if it is present, remove it without using lodash.
const idx = state.rolesFilter.findIndex(
role => role === action.payload,
);
if (idx === -1) {
nextState.roles.push(action.payload);
} else {
nextState.roles = state.roles.filter(role => role !== action.payload);
}