The use case here is to render something other than a Success/Failed state.
The UI supports Flows in a Finished state, though you need to return it using a state handler. For example:
from prefect import Flow, task
from prefect.engine.state import Finished
def handler(obj, old_state, new_state):
if isinstance(new_state, Finished):
return Finished("finished")
else:
return new_state
@task()
def mytask():
return 1
with Flow(name="POC2", state_handlers=[handler]) as flow:
mytask()
which will render as Blue in the UI