#It depends on#You can cast the spell
I previously had a much more complicated ruling about when an actionanswer here that I have saved in case it is takenactually important but I beleive your question can be answered by looking at the optional rule for simultaneous effects.
Xanathar's Guide to Everything provides a(p. 77) offers the following rule that clarifies when casting a concentration spell ends concentrationregarding simultaneous effects:
As soon as you start casting a spellIf two or usingmore things happen at the same time on a special ability that requires concentrationcharacter or monster's turn, your concentration on another effect ends instantlythe person at the game table – whether player or GM – who controls that creature decides the order in which those things happen. (XGE, 5)
This makes it clear that as soon as you start to cast another concentration spell Haste is ended
The question then remains whether you have already taken your action by beginning to cast the spell or whether you have only taken your action once you finish casting the spell. This question can be phrased as "When do I take my action?"
This is not exactly clear in the rules because it is rarely an issue. Mostwave of lethargy occurs at the same time as you just takeare casting the action and that is that. I will provide three possible answers, some support for each, and what each answer means with regard to your questionsecond spell.
The possible answers and how they affect the situation you described:
You have taken your action the moment you begin your action. This would mean that you could cast the concentration spell because you have already taken your action by the time the wave of lethargy hits
You have taken your action only once all parts of that action are completed. In this case you cannot cast the spell because you are stopped from taking actions once Haste ends
Taking an action is always a process that occurs over time. When you cannot take an action you also cannot be "taking" an action. Since you cannot take an action after Haste ends you therefore cannot complete taking the action. Since as spell only presumably creates effects after it has been cast to completion you would be unable to finish casting the spell.
The support for 1 comes from the consensus that As such you can insert a bonus action between attacks when you take the Attack action andchoose to have the Extra Attack feature. This understanding can be seen in this question about using Flurry of Blows
The support for 2 canspell be found in Sage Advicecast first and unofficial tweets regarding the Shield Master feat:
To begin the Sage Advice Compendium says that the Shield Master feat cannot be used to make a bonus action shove before the attack action has been taken. You can choose when to take Bonus Actions so long as the trigger has been satisfied so if you "take the Attack action" as soon as you decide to do so then you would be able to "Take the Attack action --> Use your bonus action to shove --> make an attack --> possibly make an extra attack" which would be functionally equivalent to using the bonus action before taking the Attack action. Since using a bonus action is not allowed before taking the Attack Action we can conclude that you do not take the action as soon as you decide to do so.
The support for option 3 can be found in this answer to Medix2's question about when the Attack action occurs
It is difficult to entirely accept a single ruling because they all seem to create issues with other features. When the rules fail I recommend relying on an imagined understanding of the in-game scenario. The Hastened wizard begins casting Invisibility. As soon as they begin casting, however, their concentration is broken and a wave of lethargy sweeps over them. They lack the strength to finish casting and so the spell fails/isn't casttake effect after.