Clearance of Title

Hi, I have come across one property need your guidance. Property land was owned by one party who died after his death the land was transferred to his wife. Builder naming XYZ got into agreement with land owner and agreed to develop the land and as an compensation will handover 3 flats (one Floor) to Land owner. Post completion of building Builder handed over the flats to Land owner giving her possession and Allotment letter. Now the land owner sold this flat to Z person with and agreement on stamp paper in the year 1990 but this was not registered. In 2002 Z person sold the flat to Y person who has done proper agreement and registered the same. Now Y person wants to sell the flat in 2023 where i am interested in buying this flat but confused as will there be any issue in future due to non registration of 1st agreement between Land owner and Z person. Also building has done the conveyance in building society name. Can you please suggest we whether i can go ahead and buy this property or no.