Dejo una solucion que yo implemente, pero pueden existir muchas mas variantes.
CodeSanbox --> Codigo
const tableRelatedNames = () => {
const tableMap = {};
arrayTest.map((arrayItem) => {
const { table } = arrayItem;
if (!tableMap[table.id]) {
tableMap[table.id] = table;
}
});
arrayTest.map((arrayItem) => {
const { table } = arrayItem;
const { join_with } = table;
if (join_with) {
const joinedTables = [];
join_with.split(",").map((joinTabledId) => {
if (tableMap[joinTabledId]) {
joinedTables.push(tableMap[joinTabledId].name);
}
});
if (joinedTables.length > 0) {
joinedTables.map((tableName) => {
console.log(
`Table ${table.id} has been joined with table: ${tableName}`
);
});
}
}
});
};[![introducir la descripción de la imagen aquí][1]][1];
tableRelatedNames();