The issue is that the wherePivot method is looking for a column named pivot in the pivot table, but the actual name of the pivot table is gebruiker_onkost. To fix this, you need to pass the name of the pivot table as the third argument to the wherePivot method. Here's the corrected query:
$gebruikers = Gebruiker::whereHas('onkosten', function ($query) use ($thisMonth, $thisYear) {
$query->whereMonth('datum', '=', $thisMonth)
->whereYear('datum', '=', $thisYear)
->where('goedgekeurd', '=', 2)
->wherePivot('isGefactureerd', false, 'gebruiker_onkost');
}) ->with(['onkosten' => function ($query) use ($thisMonth, $thisYear) {
$query->whereMonth('datum', '=', $thisMonth)
->whereYear('datum', '=', $thisYear)
->where('goedgekeurd', '=', 2)
->wherePivot('isGefactureerd', false, 'gebruiker_onkost');
}])->get();