array_merge is used in a loop and is a resources greedy construction.
You can get the $arraysToMerge using the array_column() function on $users like
this:
$arraysToMerge = array_column($users, 'socialMediaAccounts');
$arraysMerged = array_merge(...$arraysToMerge);
Matt suggested that you don't need to merge into an empty array, so I adapted
the code to his suggestion.