@hfalucas There's no easy way when you're querying user, but just do this:
$userId = 1;
$callback = function ($q) use ($userId) {
$q->where('users.id', $userId);
};
$categories = Category::with(['products' => function ($q) use ($callback) {
// get only products of the user
$q->whereHas('users', $callback);
}])
// get only categories of the user (through products)
->whereHas('products.users', $callback)
->get();

