export const flattenArrayOfObjects = (array, key) => {
    return array.reduce((acc, obj) => {
        if (Array.isArray(obj[key])) {
            acc.push(...flattenArrayOfObjects(obj[key]));
        } else {
            acc.push(obj);
        }
        return acc;
    }, []);
};