Both are in their idealism and rhetoric liberation movements (when in the opposition). Nationalism is arguing for a united nation struggling for a country of their own to exercise their self-determination. While the communist narrative asks for a united working class to strive for a society of it's own to exercise their self-determination both economically and politically.
So if you follow pure pragmatism with the goal of rallying up and organizing people towards a revolution against an oppressor then you can just focus on "us vs them narratives" and "a necessity for unity and an organized rebellion" on the one hand and talks of communal spirit and political and economic freedom, prosperity and self-determination on the other hand.
Conveniently ignoring for the moment that the two ideologies use these ideas very differently and concrete practical proposals as to how to achieve these things may very drastically, same with questions regarding who's part of the in-group and who's part of the out-group. But when it comes to organizing a rebellion often times beggars and choosers.
Also worth nothing that this goes both ways. Like a nationalist movement can insert their quest for a nation of their own in the liberation struggle of a communist party (if that already has an organization, resources, maybe outside support and whatnot), as well as a communist party lending their support to a nationalist movement that is close to achieving a critical level of dissatisfaction with a system. They would hit the same beats and try to shift the melody towards their favorite lyrics.
And as far as I know that became the most relevant in former colonial systems. Often enough colonial powers worked with a divide and conquer strategy where they didn't take control themselves but rather supported a puppet regime that was strong enough to keep the managerial control, but weak enough to rely on the colonial power to back them up if needed and thus not to establish independence of their own. So there again was an overlap between a class and nationalist struggle, where the ruling class and their supporters could be seen as a convenient enemy to rally against that both reflects a nationalist as well as a class struggle.
However when the struggle had been successful, which it often was if they were able to rally large parts of the population in a collective existential struggle, things usually fell apart again. Sure a "socialist country" would still exemplify versions of nationalism if it persisted as an independent country and/or would be placed under a different puppet regime this time by a "communist" state that support the revolution, while if the nationalist side was stronger the communist preface of the revolution is likely dropped or made more symbolic than ideological.
Regarding their ideology the nationalism usually demands to put the nation first so that the problems of the working class come second to the problems of the nations who's course is usually decided by the powerful people in economics and politics. Hence nationalism is not really compatible with the communist ideal and Marx rater argued for members of the proletariat to unite regardless of nationality than to have fights of nation was nation that just give more motivation to uphold the inequality and kill workers to further make a revolution more difficult.
So communism (ideally) isn't very nationalist, while nationalism also puts it's priorities elsewhere, that is not in the individual workers but in a national goal (also likely not chosen by the individual worker).
When in comes to marxist-leninist states however that organized as countries, nationalism might have been instrumental to appease people with a national goal disregarding the individual worker.