I am trying to use function from this answer
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewExpandableDocumentCommand{\switchcondition}{ O{string} m m m }
{
\use:c { fraiman_#1_switch:nnn } { #2 } { #3 } { #4 }
}
\cs_new:Nn \fraiman_string_switch:nnn
{
\str_case:nnF { #1 } { #2 } { #3 }
}
\cs_new:Nn \fraiman_token_switch:nnn
{
\tl_case:nnF { #1 } { #2 } { #3 }
}
\cs_new:Nn \fraiman_integer_switch:nnn
{
\int_case:nnF { #1 } { #2 } { #3 }
}
\cs_new:Nn \fraiman_dimen_switch:nnn
{
\dim_case:nnF { #1 } { #2 } { #3 }
}
\ExplSyntaxOff
\begin{document}
\newcommand{\Hello}{A4}
\switchcondition{\Hello}{
{A4}{It is A4}
{A5}{It is A5}
}{Oops!}
\end{document}
The problem is that I always get "Oops!", no matter how I define \Hello.
However,
\switchcondition{A5}{
{A4}{It is A4}
{A5}{It is A5}
}{Oops!}
works.

\str_case_e:nnFalso fully expands some of the token lists inside the second argument (A4andA5in the OP's example: these two are unchanged by this process unless catcodes have been severely tampered with). If expansion of only the first argument is desired, one can use variants such as\str_case:onF(exactly one expansion step) or\str_case:xnF(full expansion). This is a complement, not a criticism of the answer. :-) – frougon Jul 21 '19 at 12:14\str_case:xnFwon't work correctly in this context (called from a macro defined with\NewExpandableDocumentCommand).\str_case:enFshould, but requires a relatively recent TeX engine, otherwise it will be very slow. But\str_case:onFis always an option, if one expansion step is enough. – frougon Jul 21 '19 at 12:23