Access the current tenant in the importer resolveRecord() method

I'm using filament multitenancy. And I created an import for users. However, when I try to access the current tenant in the resolveRecord method to associate the user with the team I get Call to a member function members() on null.
public function resolveRecord(): ?User
    {
        $team = Filament::getTenant();

        $user = User::firstOrNew([
            'email' => $this->data['email'],
        ]);

        $team->members()->associate($user->id);

        return $user;
    }

My team model has
public function members(): BelongsToMany
    {
        return $this->belongsToMany(User::class);
    }
Was this page helpful?