Вот вам для примера
https://jsfiddle.net/yarkov_aleksei/v2tuxeyb/1/const groups = [
{ id: 1, name: 'group 1', items_ids: [1, 2, 4] },
{ id: 2, name: 'group 2', items_ids: [8, 2, 3] },
{ id: 3, name: 'group 3', items_ids: [12, 1] },
{ id: 4, name: 'group 4', items_ids: [] },
{ id: 5, name: 'group 5', items_ids: [] },
]
const result = groups
.filter(group => group.items_ids.length > 0)
.reduce((prev, next, i, acc) => prev.concat(next.items_ids), [])
console.clear()
console.log(result) // [1, 2, 4, 8, 2, 3, 12, 1]
console.log([...new Set(result)]) // [1, 2, 4, 8, 3, 12]