Need help! Checking for existence of component always returns false.

There’s probably some obvious/stupid reason, but for now my brain is not functioning. I am trying to check if a TMP inputfield component exists with the following code but am experiencing issues

    bool checkTMPInput()
    {
        Debug.Log("===================> TEST FUNC 1 !!!!!! " + GetComponent<TMPro.TMP_InputField>() != null);
        Debug.Log("===================> TEST FUNC 2 !!!!!! " + GetComponent<TMPro.TMP_InputField>() == null);

        if (GetComponent<TMPro.TMP_InputField>() != null)
        {
            Debug.Log("True");
            return true;
        }
        else
        {
            Debug.Log("False");
            return false;
        }
    }

This produces the follow results in the console

True
False
False

Yes, it does not print the “===================> TEST FUNC 1 !!!” portion, just the results, but more importantly, although “GetComponent<TMPro.TMP_InputField>() != null” evaluates correctly to “True” in the debug statement, it evaluates to false in the if statement.

Any idea what is happening?

I think this is not what is actually happening in your code. The first logged true probably does not refer to your logical expression but is somehow mangled with that string concatenation and possibly implicit type conversions. I don’t know from the top of the head all operator precedences included here but I suspect it to be more complex than you think it is.
My suggestion to be sure is to split the expression and store it into different var variables. When you point your mouse over them your IDE should tell you the type which it represents.