What are the rules for legalizing the stay of Ukrainian citizens who do not have valid documents and have been in Poland for some time (before the war)?

Update: 31.01.2023

In the case of disclosure of the illegal stay of a foreigner on the territory of the Republic of Poland, which had started before the outbreak of the war in Ukraine, the consequences may be imposed on the foreigner, most often consisting in obliging the foreigner to return and setting the foreigner a period of 15 to 30 days for voluntary return and on the prohibition of re-entry against the foreigner. in the territory of the Republic of Poland and other countries of the Schengen area for a period from 6 months to 3 years (in extreme cases up to 5 years).
However, currently, under the Act on special solutions related to the prevention, counteraction and combating of COVID-19, other infectious diseases and emergencies caused by them, if the last day of the voluntary return period falls during the period of the epidemic threat or epidemic state announced in connection with COVID- 19, this period is extended to the expiry of the 30th day following the date of recall of the last in force from the states.
Pursuant to the Act of January 13, 2023, amending the Act on Assistance to Citizens of Ukraine in Connection with Armed Conflict on the Territory of Ukraine and Certain Other Acts, on August 24, 2023, the rule described above will cease to apply, even if there is still a state of epidemic or epidemic threat in Poland. Thus, it will become necessary to leave the territory of Poland.

Regardless of the “covid” act, the Act on Assistance to Citizens of Ukraine in Connection with an Armed Conflict in the Territory of that State (Special Act) provides that if the deadline for voluntary return specified in the decision issued to a citizen of Ukraine falls in the period from February 24, 2022, it is extended by operation of law for a period of 18 months.
Furthermore, in the period until August 24, 2023, Polish services should not initiate proceedings to oblige a foreigner to return, against a citizen of Ukraine, and should discontinue the initiated proceedings in this case, if it is supported by the important interest of the said citizen. This does not apply to a situation in which the foreigner’s obligation to return is justified by reasons of defence or state security or the protection of public security and order or the interests of the Republic of Poland.

These special legal solutions allow foreigners (in the case of the covid law – everyone, and in the case of the Special Law – a citizen of Ukraine) to stay in the territory of the Republic of Poland for a specified period, despite the foreigner’s obligation to return and setting a deadline for him to voluntarily leave the territory of the Republic of Poland.
Situations related to the lack of valid documents allowing for legal stay in the territory of the Republic of Poland are so complex issues that they require individual legal consultations. After a detailed examination of a specific case, it may even turn out that it is possible to legalize the illegal stay of a foreigner without having to leave the territory of the Republic of Poland.