The specific problem is that data nested inside of text components (i.e item hovers) are not traversed when un-flattening. As a result, text components on item hovers are not un-flattened.
1.21.4 give command:
/give @p minecraft:written_book[minecraft:written_book_content={author:"",title:"",pages:['{"text":"test","hoverEvent":{"action":"show_item","contents":{"id":"minecraft:stone","count":1,"components":{"minecraft:custom_name":"{text:a,underlined:true}"}}}}']}]
See screenshot for how it currently converts to 1.21.7.
Environment
Irrelevant
Thank you for your report!
After consideration, the issue is being closed as Won't Fix.
Please note that this is not the same as Working as Intended, as this bug report correctly describes behavior in the game that might not be the intended or desirable behavior, but it will not be fixed right now. Sometimes, this is because the issue reported is minor and/or impossible to change without large architectural changes to the code base.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki