Extension method for getting custom Principal Claim
Sometimes breaking things up into smaller manageable chunks makes them easier to swallow

Break the responsibilities up into more focused concerns.

public static class PrincipalExtension {
    /// &lt;summary&gt;
    /// Retrieves the Firm Id claim if it exists
    /// &lt;/summary&gt;
    public static long? GetFirmId(this IPrincipal principal) {
        return long.TryParse(principal.FindFirstOrEmpty(nameof(User.FirmId)), out var firmId)
            ? firmId
            : default(long?);
    }
    /// &lt;summary&gt;
    /// Retrieves the first claim that is matched by the 
    /// specified type if it exists, String.Empty otherwise.
    /// &lt;/summary&gt;
    public static string FindFirstOrEmpty(this IPrincipal principal, string type) {
        return principal is ClaimsPrincipal p
            ? p.FindFirst(type)?.Value ?? string.Empty
            : string.Empty;
    }
}


FindFirstOrEmpty handles the finding of the claim value if it exists.

This allows the main function to perform its designed role.