David's suggestion satisfies all the requirements. \pdfstrcmp expands its arguments before comparison and is itself expandable.
Note the implementation is engine specific and so an extra package needs loading if lualatex is used.
\documentclass{scrartcl}
%%%%%%%%%%%%% WORKS FOR LUA + XELATEX + PDFLATEX ENGINES
\usepackage{pdftexcmds}
\makeatletter
\let\strcmp\pdf@strcmp
\makeatother
%%%%%%%%%%%%% WORKS ONLY FOR PDFLATEX AND XELATEX ENGINES
%\let\strcmp\pdfstrcmp
%%%%%%%%%%%%% END
\newcommand{\ifstringeqx}[4]{%
\ifnum\strcmp{#1}{#2}=0 #3\else#4\fi
}
\begin{document}
\def\hello{Hi}
\def\world{Earth}
\section{\ifstringeqx{\hello\world}{HiEarth}{Yes}{No}}
\def\world{Saturn}
\def\planet{Saturn}
\ifstringeqx{\hello\world}{Hi\planet}{Yes}{No}
\edef\isitexpandable{\ifstringeqx{\hello\world}{HiJupiter}{Yes}{No}}
---$>$ \isitexpandable
\end{document}

SUPPLEMENT
If one is concerned with the \else and/or \fi in the definition of \ifstringeqx getting in the way of #3 and #4 doing their thing (for example, if they need to absorb tokens located beyond the \fi), we can copy/paste a little bit of logic from the tokcycle package to perform the \ifnum while removing the influence of \else and \fi:
\makeatletter
\long\def\tctestifnum#1{\tctestifcon{\ifnum#1\relax}}
\long\def\tctestifcon#1{#1\expandafter\tc@exfirst\else\expandafter\tc@exsecond\fi}
\long\def\tc@exfirst#1#2{#1}
\long\def\tc@exsecond#1#2{#2}
\makeatother
\newcommand{\ifstringeqx}[4]{%
\tctestifnum{\strcmp{#1}{#2}=0}{#3}{#4}}
Here's an example where the original definition with \else and \fi won't work, but this revised definition works fine.
\documentclass{scrartcl}
%%%%%%%%%%%%% WORKS FOR LUA + XELATEX + PDFLATEX ENGINES
\usepackage{pdftexcmds}
\makeatletter
\let\strcmp\pdf@strcmp
\makeatother
%%%%%%%%%%%%% WORKS ONLY FOR PDFLATEX AND XELATEX ENGINES
%\let\strcmp\pdfstrcmp
%%%%%%%%%%%%% END
\makeatletter
\long\def\tctestifnum#1{\tctestifcon{\ifnum#1\relax}}
\long\def\tctestifcon#1{#1\expandafter\tc@exfirst\else\expandafter\tc@exsecond\fi}
\long\def\tc@exfirst#1#2{#1}
\long\def\tc@exsecond#1#2{#2}
\makeatother
\newcommand{\ifstringeqx}[4]{%
\tctestifnum{\strcmp{#1}{#2}=0}{#3}{#4}}
\def\Yes#1{#1 yes!}
\def\No#1{#1 no!}
\begin{document}
\def\hello{Hi}
\def\world{Earth}
\section{\ifstringeqx{\hello\world}{HiEarth}{\Yes}{\No}{Hell}}
\def\world{Saturn}
\def\planet{Saturn}
\ifstringeqx{\hello\world}{Hi\planet}{Yes}{No}
\edef\isitexpandable{\ifstringeqx{\hello\world}{HiJupiter}{\Yes}{\No}{Absolutely}}
---$>$ \isitexpandable
\end{document}

base. – campa Aug 23 '21 at 14:49\pdfstrcmppdftex primitive for the stated use case – David Carlisle Aug 23 '21 at 15:15