How to consistently check if the code is executing on server/client when playing in editor?

I’ve been writing some networking back and forth code for client and server so I’ve added sanity checks in functions that are supposed to only ever be run on server or client.

However, when playing in editor, I cannot find a way to reliably get the information if the code is running on what would be server or on what would be client.

Firstly, in Editor Preferences, I enabled option Launch Separate Server and am running the game as Play As Client.

I have a reliable client RPC that has a APlayerController as an argument. Since player controllers exist both on server and client, RPC should do some magic in the background so that when the function is executed on the client, the appropriate player controller is set as the argument of the function.

This is what the definition of RPC looks like:

UFUNCTION(Client, Reliable)
void Client_AdminSettingsNotifyLockOwnerChanged(APlayerController* playerController);

The implementation is as follows:

void UPlayerRpcChannel::Client_AdminSettingsNotifyLockOwnerChanged_Implementation(APlayerController* playerController)
{
	FAdminSettings::Get()->LockOwnerChanged_Client(playerController);
}

LockOwnerChanged_Client is just a regular function. I know this function should only be executed on server, so it looks like this:

void FAdminSettings::LockOwnerChanged_Client(APlayerController* playerController)
{
	if (IsServer(playerController))
	{
		UE_DEBUG_BREAK();
		return;
	}

	// do something
}

I’ve been having trouble finding what to check for in the IsServer function so I’d get a proper result. What I’ve tried so far:

GetNetMode() on the passed controller → I get NM_DedicatedServer
GetLocalRole() on the passed controller → I get ROLE_Authority

I’ve also tried using
UGameplayStatics::GetGameMode(playerController) != nullptr
to check if I’m the dedicated server since AGameMode does not exist on clients.

I also tried IsRunningDedicatedServer() but this always returns false when running PIE.

Now, I understand that the editor is what it is, but how the hell can I tell if the code is executing on what would be dedicated server in shipping or what would be client on shipping?