Ok, so line 50 setts the $EmailRef variable which is a unique reference to the UE instance on this page
$EmailRef = "waue_contact_1";
line 118 uses that $EmailRef variable in the name of the status session:
$_SESSION[$EmailRef."_Status"] = $GLOBALS[$EmailRef."_Status"];
so for this page the session is named
waue_contact_1_Status
posible values are "Success" or "Failure", it will equal Success if the email was compiled and passed to the SMTP server. It will equal Failure if the SMTP server could not be connected to, or there was a problem with the format of the from or to addresses.
so we can change the if statement to use the status session as a trigger, we will also want to clear the status session so that a page reload will show the form:
<?php @session_start(); ?>
<?php if(isset($_SESSION['waue_contact_1_Status']) && $_SESSION['waue_contact_1_Status'] == "Success") { ?>
Thank you message
<?php } else { ?>
<form>
<?php } ?>
<?php if(isset($_SESSION['waue_contact_1_Status'])) unset($_SESSION['waue_contact_1_Status']); ?>