Why won’t is_search work inside functions.php?

… the call works fine as it actually echos “nope” where it’s supposed
to, are you saying that it may be a problem because I’m making an ajax
call which is not search.php?

An Ajax call is a new request to the server. The page that loads is (should be) wp-admin/admin-ajax.php which is template neutral. That is not a search page at all. is_search won’t ever be true. What is_search does, in short, is check the main query to see if you are on a search results template page. With an AJAX call to admin-ajax.php, you aren’t.

You could probably just remove that check as presumably your function is only used where appropriate, but you’d need to provide more context for a solid answer.