this.prepData.filter(e=>e.workflowRoleDesc!=s)[1].userList.filter(e=>e.value != filteredData.map(e=>e.userId))
this.prepData
basically looks like this, inside userList
we have another array which has a field called value.
0: {workflowRoleDesc: 'Preparer', userList: Array(61), isRoleEnable: true}
1: {workflowRoleDesc: 'Reviewer', userList: Array(44), isRoleEnable: true}
2: {workflowRoleDesc: 'Approver', userList: Array(49), isRoleEnable: true}
length: 3
[[Prototype]]: Array(0)
s
is string variable which can have one of the following value at a time Preparer
, Reviewer
or Approver
.
and
filteredData.map(e=>e.userId)
(2) ['86cb7ae5-2b56-4437-af5a-115018d69403', '188e20db-db56-41c9-9bfa-20c7d02b4da0']
In the second filter when I am using filteredData.map(e=>e.userId)
, it does not filter anything but if I give the value '86cb7ae5-2b56-4437-af5a-115018d69403' directly it is working as expected.
What can I do to make it work?
Well, you are comparing a value
(which seems to be a string) with an array of strings filteredData.map(e=>e.userId)
. Maybe you should use:
this.prepData
.filter(e=>e.workflowRoleDesc!=s)[1]
.userList.filter(e=>filteredData.map(e=>e.userId).indexOf(e.value) < 0)
Meaning that you want to use the users that are NOT among the filteredData
ones.