With your code \yesifone{\one} yields the tokens
\yesifone{1\one}2
This expands to
\ifnum112=12\one\relax{1y11e11s11}2\else{1n11o11}2\fi.
At the time of gathering tokens that belong to \ifnum's second TeX-⟨number⟩-quantity, i.e., the number behind =12, the token \one gets expanded, thus you have s.th. like
\ifnum112=12␣10\blah{1}2␣10112␣10\relax{1y11e11s11}2\else{1n11o11}2\fi.
Space-tokens ␣10 right behind =12 get removed and \blah gets expanded and just vanishes as its replacement-text is empty. Thus you have s.th. like:
\ifnum112=12{1}2␣10112␣10\relax{1y11e11s11}2\else{1n11o11}2\fi.
So at the time of gathering tokens that belong to \ifnum's second TeX-⟨number⟩-quantity, i.e., the number behind =12, TeX finds an empty brace-group, i.e., explicit-character-tokens {1 and }2, which definitely does not form the begin of a sequence of tokens that form a valid TeX-⟨number⟩-quantity.
Think about Knuth's analogy of TeX being a beast with eyes and a digestive tract.
- Expansion of expandable tokens takes place in the gullet in some sort of regurgitation process unless expansion is suppressed as is the case, e.g., with the tokens that form the parameter text or the replacement-text of a
\def-assignment. (LaTeX's \newcomand and \NewDocumentCommand etc are sophisticated wrappers for calling \def.)
- Assignments take place in the stomach.
So separate tasks like assigning values to "variables" which involve the stomach for doing non-typesetting-work from tasks where the gullet/expansion of expandable tokens is sufficient and where digestive organs behind the gullet are involved only for typesetting:
\documentclass{minimal}
% Introduce/initialize things used as variable whose value is
% to be set via assignments that take place in the stomach:
\newcommand\VariableRelatedToBlah{}
% Define macros for tasks that involve digestive organs behind the gullet for
% for non-typesetting-tasks, e.g.,setting values of variables via assignments:
\newcommand\SetValueOfVariableRelatedToBlah[1]{%
\def\VariableRelatedToBlah{#1}%
}
% Define macros for tasks that involve only the gullet, e.g.,
% retrieving values of variables, or additionally to the gullet
% involve digestive organs behind the gullet only for typesetting:
\newcommand\RetrieveValueOfVariableRelatedToBlah{%
\VariableRelatedToBlah
}
\newcommand\firstofone[1]{#1}%
\newcommand{\yesifone}[1]{%
\ifnum1=\expandafter\firstofone\expandafter{\number#1} yes\else no\fi
}
\begin{document}
% Now you can keep work that involves the stomach for non-typesetting
% separated from work where the gullet is sufficient/where tokens
% delivered by the gullet can directly be used for typesetting:
\SetValueOfVariableRelatedToBlah{0}%
\yesifone{\RetrieveValueOfVariableRelatedToBlah}
\SetValueOfVariableRelatedToBlah{1}%
\yesifone{\RetrieveValueOfVariableRelatedToBlah}
\end{document}

\blahis expandable you can simply omit the{}after it, but I suspect your real case is not expandable. Otherwise you really can't do that in general you should arrange that you leave the test token somewhere that is accessible by expansion see how pgf/tikz leaves values in\pgfresultrather than reurning them directly. – David Carlisle May 10 '22 at 10:28\def\blah#1{}to\yesifoneso that the{}are removed. – David Carlisle May 10 '22 at 10:34